def fib(n): a = 0 b = 1 dic = {} ## {} or dict() 3分 for i in range(n): ## range 3分 dic[i]=a ## a 3分 a,b=b,a+b return dic ## dic 3分 #调用函数生成斐波那契数列中的前20个斐波那契数 fibonac = fib(20) ## fib(20) 调用函数 3分 for key in fibonac.keys(): print(fibonac[key], end=",")