Python核心编程(切片索引的更多内容) # coding=utf8 s = 'abcde' i = -1 for i in range(-1, -len(s), -1): print(s[:i]) # 结果 ''' abcd abc ab a '''