def add(n,i):
return n+i
def test():
for i in range(4):
yield i
g=test()
for n in [1,10]:
g=(add(n,i) for i in g)
print(n)
print(list(g))
‘‘‘
# 问:为什么?
结果:
10
[20, 21, 22, 23]
‘‘‘
原文:https://www.cnblogs.com/guanxiying/p/12578001.html