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' >>>
无语言基础,自学python所做的各种笔记,欢迎大牛指点.