python 导包警告 Using or importing the ABCs from ‘collections’ instead of from ‘collections.abc’ is deprecated since Python 3.3, and in 3.10 it will stop working
代码如下(示例):
from collections import Iterator
print(isinstance(iter([]), Iterator)) # True
# 控制台输出:
# D:\Code_data\pycharm project\first test\08-iterable.py:2: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working
# from collections import Iterator
# True
虽然结果出来了,但是一直有个烦人的警告(Using or importing the ABCs from ‘collections’ instead of from ‘collections.abc’ is deprecated since Python 3.3, and in 3.10 it will stop working),不仔细看,还以为代码哪里报错了
解决办法就是将
from collections import Iterator
改为
from collections.abc import Iterator