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]

开阔眼界了

posted @ 2013-10-29 22:16  hailπ  阅读(400)  评论(0编辑  收藏  举报