1 def f1(): 2 print(11) 3 yield 1 4 5 print(22) 6 yield 2 7 8 print(33) 9 yield 310 11 print(44)12 yield 413 14 f11 = f1()15 ret = f11.__next__()16 print(ret)17 ret = f11.__next__()18 print(ret)19 ret = f11.__next__()20 print(ret)21 ret = f11.__next__()22 print(ret)
结果:
11
1222333444