python3 yield实现斐波那契数列

def fab(max): n,a,b = 0,0,1 while n < max: yield a+b a,b = b,a+b n += 1 for i in fab(5): print(i)
相关文章
相关标签/搜索