python函数、类与对象,魔法方法

def libs(n):
a = 0
b = 1
while True:
a, b = b, a + b
if a > n:
return
yield a

for each in libs(100):
print(each, end=’ ')

1 1 2 3 5 8 13 21 34 55 89

猜你喜欢

转载自blog.csdn.net/qq_37795916/article/details/115539627