标签:北京 class int span 应用 produce producer next tar
初步了解协程
def eater(): print(‘start to eat‘) while True: food=yield print(‘is eating food:%s‘%food) def producer(): dog=eater() next(dog) # 先next一次唤醒协程函数 #然后下面的操作都是dog.send(值) food1=‘北京烤鸭‘ food2=‘鱼香肉丝‘ dog.send(food1) dog.send(food2) producer() 输出结果: start to eat is eating food:北京烤鸭 is eating food:鱼香肉丝
更新中。。。
更新中。。。
标签:北京 class int span 应用 produce producer next tar
原文地址:http://www.cnblogs.com/ylqh/p/6523659.html