方法一:
适用于python2和python3
>>> from collections import iterable
>>> isinstance(“str”, iterable)
true
方法二:
适用于python3
s = “hello world”
hasattr(s, “__iter__”)
更多[python][基础]判断变量是否可迭代相关文章请关注php中文网!
A programmer’s note boke for work and life
方法一:
适用于python2和python3
>>> from collections import iterable
>>> isinstance(“str”, iterable)
true
方法二:
适用于python3
s = “hello world”
hasattr(s, “__iter__”)
更多[python][基础]判断变量是否可迭代相关文章请关注php中文网!