标签:ext UNC function col list color rom 循环 span
"""可迭代:可循环--一个实现了next方法的对象则是迭代器 一类是集合数据类型,如list/tuple/dict/set/str 一类是generator,包括生成器和带yield的generator function""" from collections import Iterable isinstance({},Iterable) class Fibs: def __init__(self): self.a=0 self.b=1 def __next__(self): self.a, self.b= self.b, self.a+self.b return self.a def __iter__(self): return self fibs=Fibs() for i in fibs:#由于Fibs可迭代,所以fibs可迭代 if i<100: print (i)
标签:ext UNC function col list color rom 循环 span
原文地址:https://www.cnblogs.com/xiaozeng6/p/13170813.html