from collections import Iterable
print(isinstance({},iterable)) # 判断是否可迭代
from collections import Iterator #判断是否是迭代器
instance((x for x in range(5)),Iterator)) #生成器一定是迭代器
a = [1, 2, 3]
b = iter(a) #变成一个迭代器
print(b.__next__()) #读取一次生成器
it = iter([1, 2, 3, 4, 5, 6])
while True:
try:
f = next(it) #读取一次生成器
print (f)
excpet StopIteration:
break