标签:font 调用 iter instance int break 函数调用 style ble
总结:
简单理解:
from collections.abc import Iterable
isinstance([],Iterable)
isinstance({},Iterable)
isinstance("abc",Iterable) #可迭代对象
isinstance(iter(‘abc‘),Iterable) #迭代器
isinstance(100,Iterable) #false,不可以迭代
isinstance((x for x in range(100)),Iterable)
例子
it =iter([1,2,3,5,6])
while True:
try:
x = next(it)
# print(x)
except StopIteration:
break
#下面代码等价
for x in [1,2,3,4,5,6]:
pass
标签:font 调用 iter instance int break 函数调用 style ble
原文地址:https://www.cnblogs.com/mygodswangzi/p/11896745.html