itertools.cycle().next()?

前端 未结 2 1205
醉酒成梦
醉酒成梦 2020-12-05 12:59

Well, I was using itertools.cycle().next() method with Python 2.6.6, but now that I updated to 3.2 I noticed that itertools.cycle() object has no m

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-05 13:35

    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

提交回复
热议问题