1. 代码
def create_num(all_num):
a, b = 0, 1
current_num = all_num
while current_num < all_num:
ret = yield a
print(">>>>>>>>", ret)
a, b = b, a + b
current_num += 1
obj = create_num(10)
# obj.send(None) # send 一般不会放在第一次启动生成器,如果非要这么做,那么传递None
res = next(obj)
print(res)
# send 里面的数据会传递给第5行, 当做yield a 的结果,然后ret保存这个结果
# send 的结果是下一次调用yield时,yield后面的值
res = obj.send("dagehao")
print(res)