range(start, stop, step)
1 l = [1,2,3,4,5,6,7,8,9] 2 print l[2:] 3 print l[:2] 4 print l[::2] 5 print l[-2:] 6 print l[:-2] 7 print l[::-2]
python2.7,输出如下:
[3, 4, 5, 6, 7, 8, 9] [1, 2] [1, 3, 5, 7, 9] [8, 9] [1, 2, 3, 4, 5, 6, 7] [9, 7, 5, 3, 1]
标签:art size nbsp post stop 输出 2.7 bsp color
range(start, stop, step)
1 l = [1,2,3,4,5,6,7,8,9] 2 print l[2:] 3 print l[:2] 4 print l[::2] 5 print l[-2:] 6 print l[:-2] 7 print l[::-2]
python2.7,输出如下:
[3, 4, 5, 6, 7, 8, 9] [1, 2] [1, 3, 5, 7, 9] [8, 9] [1, 2, 3, 4, 5, 6, 7] [9, 7, 5, 3, 1]
标签:art size nbsp post stop 输出 2.7 bsp color
原文地址:https://www.cnblogs.com/qianzeng/p/8476405.html