生成器面试题 遇到for循环先列出来
def add(n,i): return n+i def test(): for i in range(4): yield i g=test() for n in [1,10,3]: g=(add(n,i) for i in g) ''' n=1 g=(add(n,i) for i in g) n=2 g=(add(n,i) for i in g) n=3 g=(add(n,i) for i in g) n=3 #g=(add(n,i) for i in add(n,i) for i in add(n,i) for i in test()) n=0 1 2 3 9 10 11 12 6 7 8 9 3 4 5 6 ''' print(list(g))