标签:for code iter iterator cal 否则 __call col return
class Counter(object): def __init__(self): self.i = [1,2,3,4,5,6] self.n = iter(self.i) def __call__(self): x = next(self.n) print(‘call‘,x) return x it = Counter() t1 = iter(it, 5) # it必须是callable的,否则无法返回callable_iterator for v in t1: print(v) # 结果 call 1 1 call 2 2 call 3 3 call 4 4 call 5
标签:for code iter iterator cal 否则 __call col return
原文地址:https://www.cnblogs.com/daicw/p/12090485.html