This commit is contained in:
sherlockforrest
2023-06-20 09:22:53 +08:00
commit bf2ed2e31f
621 changed files with 271599 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
"""
生成器 - 使用yield关键字
Version: 0.1
Author: 骆昊
Date: 2018-03-21
"""
def fib(num):
n, a, b = 0, 0, 1
while n < num:
yield b
a, b = b, a + b
n += 1
for x in fib(20):
print(x)