Py学习  »  问与答

为啥两个结果不一致

727201287 • 4 年前 • 395 次点击  
def f():
    L = [1,2]
    yield L
    L.append(0)
r = []
for i in f(): 
    print(i)
    r.append(i)
print(r)

输出: [1, 2] [[1, 2, 0]]

最后一次修改于 (2019-06-21 14:11)
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/35003
 
395 次点击