1 s = 'abcde' 2 i = -1 3 for i in range(-1, -len(s), -1): 4 print s[:i] 5 6 for i in [None] + range(-1, -len(s), -1): 7 print s[:i]
用[None]想加可以得到想要的结果,即能够获取全部字符串