当判断iterable得到NameError: name 'Iterable' is not defined

244*_*boy 3 python

我按照教程:

在此处输入图片说明

在我的 PyCharm 中,我按照教程进行操作:

在此处输入图片说明

我收到错误:

回溯(最近一次调用):文件“/Users/adob/TestPython/test02/passwd.py”,第 19 行,在 bool = isinstance({}, Iterable) NameError: name 'Iterable' 未定义

Har*_*ngh 6

from collections import Iterable

bool = isinstance({},Iterable)
print(bool)
Run Code Online (Sandbox Code Playgroud)

输出

真的

  • 在 Python 3.7 中,它被标记为已弃用。改用`from collections.abc import Iterable`。 (3认同)