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]]