class Fab(object):
def __init__(self ,max ):
self.max =max
self.n =0
self.a=0
self.b =1
def __iter__(self): #迭代器,表示为容器,相当于声明
return self
def __next__(self): #迭代内容
print('n=',self.n)
self.n=1+self.n
if self.n < self.max:
out = self.b
return out
# raise StopIteration()
c=0
for i in Fab(13):
c=1+c
print(i)
print('c=',c)
if c>20:
# a = Fab(3)
# print(a)
break

相关文章:

  • 2022-12-23
  • 2021-08-06
  • 2021-07-21
  • 2022-12-23
  • 2021-07-31
  • 2022-12-23
  • 2021-08-05
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2018-09-14
  • 2021-06-16
  • 2021-09-20
  • 2021-05-25
相关资源
相似解决方案