发布日期 :2017-11-04 13:00:14 UTC
访问量: 260 次浏览
方法一: 适用于Python2和Python3:
>>> from collections import Iterable >>> isinstance("str", Iterable) True
方法二:
只适用于Python3
>>> s = "hello world" >>> hasattr(s, "__iter__")