1 #Author : Kelvin 2 #Date : 2019/1/22 20:02 3 class Fi: 4 def __init__(self): 5 self.a=1 6 self.b=1 7 def __iter__(self): 8 return self 9 def __next__(self): 10 if self.b>100: 11 raise StopIteration("out of range") 12 self.a,self.b=self.b,self.a+self.b 13 return self.a 14 import time 15 f=Fi() 16 for i in f: 17 print(i) 18 time.sleep(1)