第一种 s = (x*2 for x in range(5)) 第二种 yield 方式 def foo(): print('ok') yield 1 g = foo() print(g) next(g)