AttributeError: 'callable_iterator' object has no attribute 'next',python3中迭代器的next()方法已变成__next__()

报错信息:

Traceback (most recent call last):

  File "F:/unit1/01_03.py", line 149, in <module>
    g = it.next()

AttributeError: 'callable_iterator' object has no attribute 'next'


解决办法:

将上述代码中调用next()的地方全部替换为__next__(),最后在控制台运行该代码,正确得到了预期的结果

猜你喜欢

转载自blog.csdn.net/beta_safe/article/details/80149520