def FB(n): a,b=0,1 while n>0: yield b a,b=b,a+b n-=1 def FB2(n): return list(FB(n)) 转载于:https://www.cnblogs.com/zhibin123/p/11099859.html