迭代器
迭代器:
from collections import Iterator
isinstance('abc',Iterator)
a = iter('abc') #iter可以把序列类型变成Iteratable 类型
print(isinstance(a,Iterator))
print(a.__next__())
print(a.__next__())
print(a.__next__())
生成器用迭代器迭代:
from collections import Iterator
def func(n):
count=0
while count<n:
count+=1
yield count
print(count)
ss = func(3)
next(ss)
next(ss)
print(isinstance(iter(ss),Iterator))
next(ss)