an object is determined python iterable

So, how to judge an object is iterable it? It is determined by the type Iterable collections module:

>>> from collections import Iterable
>>> isinstance('abc', Iterable) # str是否可迭代 True >>> isinstance([1,2,3], Iterable) # list是否可迭代 True >>> isinstance(123, Iterable) # 整数是否可迭代 False

Guess you like

Origin www.cnblogs.com/apple2016/p/10959828.html