python 斐波那契数列 fibonacci

在python中生成fibonacci数列的函数

def fibonacci():
list = []
while 1:
if(len(list) < 2):
list.append(1)
else:
list.append(list[-1]+list[-2])
yield list[-1] #1 # change this line so it yields its list instead of 1 our_generator = fibonacci()
my_output = [] for i in range(10):
my_output = (next(our_generator))
print(my_output)
上一篇:MySQL-5.7数据库主从同步实战教程


下一篇:[SOJ] connect components in undirected graph