摘要: import time def consumer(name): print('%s,准备吃包子'%name) while True: baozi = yield print('包子%s来了,被%s吃了'%(baozi,name)) c = consumer('clyde') c.__next__() 阅读全文
posted @ 2020-06-15 20:04 云雾迷歌 阅读(151) 评论(0) 推荐(0) 编辑
摘要: '''生成器:1、只有在调用时才会生成相应的数据;只记录当前位置,不能后退也不能跳跃前进,只能通过__next__()方法向下走,或for循环''' #斐波那契数列 def fid(max): n,a,b = 0,0,1 while n < max: print(b) a,b = b,a+b #b, 阅读全文
posted @ 2020-06-15 20:02 云雾迷歌 阅读(159) 评论(0) 推荐(0) 编辑