def fab(n): a,b = 0,1 while n: yield b a,b = b,a+b n -= 1本文首发于python黑洞网,博客园同步更新
def fab(n):
a,b = 0,1
while n:
yield b
a,b = b,a+b
n -= 1