def consumer(name): print('我是[%s],我准备开始吃包子了' %name) while True: baozi=yield time.sleep(1) print('%s 很开心的把【%s】吃掉了' %(name,baozi)) def producer(): c1=consumer('wupeiqi') c2=consumer('yuanhao_SB') c1.__next__() c2.__next__() for i in range(10): time.sleep(1) c1.send('包子 %s' %i) c2.send('包子 %s' %i) producer()