s[-1]和s[len(s)-1]

Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>> 
>>> s='xiaodeng'
>>> s[-1]
'g'
>>> s[len(s)-1]
'g'
>>> s[-2]
'n'
>>> s[len(s)-2]
'n'
>>> 

 

posted @ 2015-10-20 11:20  Xiao|Deng  阅读(1230)  评论(0编辑  收藏  举报