itertools.cycle().next()?

百般思念 提交于 2019-11-28 08:02:00
d0ugal

iter.next() was removed in python 3. Use next(iter) instead. So in your example change itertools.cycle().next() to next(itertools.cycle())

There is a good example here along with various other porting to python 3 tips. It also compares various other next() idioms in python 2.x vs python 3.x

In Python 3.x, iterators don't have it.next() any more. use next(it) instead, which also works in Python 2.6 or above. Internally, this will call it.next() in Python 2.x and it.__next__() in Python 3.x.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!