标签:color pre ons producer __next__ while style ext 准备
import time def consumer(name): print("%s 准备吃包子啦!" %name) while True: baozi = yield print("包子[%s]来了,被[%s]吃了!" %(baozi,name)) def producer(name,name1): c = consumer(name) c2 = consumer(name1) c.__next__() c2.__next__() print("老子开始准备做包子啦!") for i in range(10): time.sleep(1) print("做了2个包子!") c.send(i) c2.send(i) producer(‘alex‘,‘bruce‘)
标签:color pre ons producer __next__ while style ext 准备
原文地址:http://www.cnblogs.com/bruce61/p/7569801.html