访问量: 227 次浏览
方法一: 适用于Python2和Python3:
>>> from collections import Iterable >>> isinstance("str", Iterable) True
方法二:
只适用于Python3
>>> s = "hello world" >>> hasattr(s, "__iter__")