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

前端 未结 6 1963
鱼传尺愫
鱼传尺愫 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:45

    To get the value associated with a generator object in python 3 and above use next(). subsequent calls to next() produces successive object values in the queue.

提交回复
热议问题