1.yield由于创建迭代器 def deal(): tmp = [] for i in range(20): tmp.append(i) if i % 4 == 0: yield tmp tmp = [] yield tmp #S1 return tmp #S2 for dd in deal(): print(dd) exit() 输出: # S1 [0] [1, 2, 3, 4] [5, 6, 7, 8] [9, 10, 11, 12] [13, 14, 15, 16] [17, 18, 1…