标签:except stop __iter__ ext try bsp top style __next__
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
标签:except stop __iter__ ext try bsp top style __next__
原文地址:https://www.cnblogs.com/li33232/p/11440404.html