2017-07-30 52 views
0

我按照教程:无法判断迭代在Python

enter image description here

在我PyCharm我按照教程:

enter image description here

我得到的错误:

Traceback (most recent call last): File "/Users/adob/TestPython/test02/passwd.py", line 19, in bool = isinstance({}, Iterable) NameError: name 'Iterable' is not defined

+0

你不应该使用的图像时,可以使用文本 –

+0

@AzatIbrakov我用的形象,因为有在网上红在这里。使用代码无法显示它。 – 244boy

回答

0
from collections import Iterable 

bool = isinstance({},Iterable) 
print(bool) 

输出

1

Iterable在collections模块,你应该导入它。

from collections import Iterable 
+0

在Py3中,另一个选项与'typing'模块的输入相同,但给定'print'语句假定OP使用Py2。 – AChampion