python 3.x 错误 ‘generator’ object has no attribute ‘next’

出现如下错误:

Traceback (most recent call last):

 File “<pyshell#32>”, line 1, in <module>
   file.next()
AttributeError: ‘generator’ object has no attribute ‘next’

原因是在python 3.x中 generator(有yield关键字的函数则会被识别为generator函数)中的next变为__next__了,next是python 3.x以前版本中的方法

修改为下面这样运行正常
file=fab(5)
file.__next__()

你可能感兴趣的:(python)