04 生成器版协程

import time

def f1():
    for i in range(10):
        time.sleep(0.5)
        print('f1>>',i)
        yield

def f2():
    g = f1()
    for i in range(10):
        time.sleep(0.5)
        print('f2>>', i)
        next(g)

f1()
f2()

  

posted on 2019-01-14 15:51  =.===  阅读(104)  评论(0编辑  收藏  举报

导航