How to get one value at a time from a generator function in Python?

前端 未结 6 1954
鱼传尺愫
鱼传尺愫 2020-12-24 04:08

Very basic question - how to get one value from a generator in Python?

So far I found I can get one by writing gen.next(). I just want to make sure this

6条回答
  •  既然无缘
    2020-12-24 04:34

    In python 3 you don't have gen.next(), but you still can use next(gen). A bit bizarre if you ask me but that's how it is.

提交回复
热议问题