Python2转Python3 中报错AttributeError: ‘generator‘ object has no attribute ‘next‘

g.next() has been renamed to g.__next__().
 The reason for this is consistency: special methods like __init__() and __del__() all have double underscores (or "dunder" in the current vernacular), and .next() was one of the few exceptions to that rule. This was fixed in Python 3.0. [*]

But instead of calling g.__next__(), use next(g).

使用__next__()代替next()即可


版权声明:本文为xyh_qianxiao原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。