📜  从列表创建生成器 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:39.055000             🧑  作者: Mango

代码示例1
data = [1,23,46,9,2]
#creates a generator object
data_gen = (y for y in data)

# creates a list iterator object
data_iter = iter(data)

# both can be used with next()

next(data_gen) 
# or
next(data_iter)