码迷,mamicode.com
首页 > 其他好文 > 详细

哦哦哦

时间:2018-07-11 17:55:30      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:producing   sum   ...   rod   turn   cin   nbsp   min   none   

def consumer():
    r = ‘‘
    while True:
        n = yield r
        if not n:
            return
        print([CONSUMER] Consuming %s... % n)
        r = 200 OK

def produce(c):
    c.send(None)
    n = 0
    while n < 5:
        n = n + 1
        print([PRODUCER] Producing %s... % n)
        r = c.send(n)
        print([PRODUCER] Consumer return: %s % r)
    c.close()

c = consumer()
produce(c)

 

哦哦哦

标签:producing   sum   ...   rod   turn   cin   nbsp   min   none   

原文地址:https://www.cnblogs.com/saolv/p/9295685.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!