l=[1,2,3,4,5] a=l.__iter__() # print(next(a)) # print(next(a)) # print(next(a)) # print(next(a)) # print(next(a)) # print(next(a)) #上面的列表长度只有5个,而你多打印了,就会报错。处理的情况如下,就不会报错了 while True: try: item=a.__next__() print(item) except StopIteration: # 异常处理 break