2017-07-30 51 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