python分片,实例演示:
复制代码 代码示例:
>>> numbers = [1,2,3,4,5,6,7,8,9,10]
>>> numbers[0:10:2]
[1,3,5,7,9]
>>> numbers[::4]
[1,5,9]
>>> numbers[8:3:-1]
[9,8,7,6,5]
>>> numbers[10:0:-2]
[10,8,6,4,2]
>>> numbers[::-2]
[10,8,6,4,2]
>>> numbers[5::-2]
[6,4,2]
>>> numbers[:5:-2]
[10,8]
相当不错吧,与perl中的分片技术是不是有一拼呢?