生成器的惰性机制
1 def func(): 2 print(111) 3 yield 1 4 g = func() 5 g1 = (i for i in g) 6 g2 = (i for i in g1) 7 8 print(list(g)) # 111 [1] 9 print(list(g1)) # [] 10 print(list(g2)) # [] 11 12 print(next(g)) # 111 1 13 print(next(g1)) # StopIteration 14 print(next(g2)) # StopIteration