yield伪并发练习
def consumer(name): print("%s 开始购买物品了!" % name) while True: item_name = yield print("物品 %s 被 %s 购买了!" % (item_name, name)) def producer(name): c = consumer("a") c1 = consumer("b") next(c) next(c1) for i in range(10): print("%s 生产了2个物品 %s" % (name, i)) c.send(i) c1.send(i) producer("aaa")