python: list[-1] 与 list[-1:] 的区别

 1 >>> l
 2 '3.542485\t1.977398\t-1\r\n'
 3 >>> l.split()
 4 ['3.542485', '1.977398', '-1']
 5 >>> l=l.split()
 6 >>> l[:2]
 7 ['3.542485', '1.977398']
 8 >>> l[2]
 9 '-1'
10 >>> l[:1]
11 ['3.542485']
12 >>> l[-1]
13 '-1'
14 >>> l[-1:]
15 ['-1']

 

posted @ 2015-01-27 23:30  monlh  阅读(9093)  评论(0编辑  收藏  举报