#生成器并行
import time
def consumer(name):
print("%s 准备吃包子啦!" %name)
while True:
baozi = yield
print("包子[%s]来了,被[%s]吃了!" %(baozi,name))
c = consumer("abc")
c.__next__()
# b1= "韭菜馅"
# c.send(b1)#send可以往yield里传值
# c.__next__()
def producer(name):
c = consumer('A'
python生成器并行
最新推荐文章于 2020-12-09 08:08:33 发布