通过collections模块的Iterable类型判断str是否可迭代
from collections import Iterable
print(isinstance('abc', Iterable))
遇到问题:
DeprecationWarning: Using or importing the ABCs from ‘collections’ instead of from ‘collections.abc’ is deprecated, and in 3.8 it will stop working from collections import Iterable
解决方案:
from collections.abc import Iterable
print(isinstance('abc', Iterable))