遇到不会的我就问ChatGPT,给了个解决方案:
from collections import Iterable
# 如果当前 Python 版本不支持 collections.abc 中的 Iterable,则手动定义
if not hasattr(Iterable, '__iter__'):
Iterable = collections.abc.Iterable然而,仍然报错。
无奈去google了下,在csdn上找到了答案:
import collections
collections.Iterable = collections.abc.Iterable这样做的目的是确保你的代码在不同的 Python 版本或环境中都能使用
collections.Iterable,而不会受到模块变化的影响。提高代码的兼容性。Rate this post