str1="abcdef" >>> str1[0:4] ‘abcd‘ #str1[0:4]等价于str[0:4:1]
反向切片,必须指定步长,且为负值
>>> str1[-1:-4:-1] ‘fed‘ #等价于 >>> str1[5:2:-1] ‘fed‘
python的切片
原文:https://blog.51cto.com/13560219/2507517