import collections模块python说不推荐使用,那他推荐的模块是哪个呢?
我导入import collections时,系统说不推荐,但我再次调用却还是能正常使用不推荐使用警告:从“collections”而不是从“collections.abc”中使用或导入abc在python3.3中已不推荐使用,在3.10中它将停止工作
那现在推荐导入哪个模块呢,能用isinstance检测是否是可迭代
>>> import collections as g
>>> list1 =
>>> f = isinstance(list1,g.Iterable)
Warning (from warnings module):
File "<pyshell#2>", line 1
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
>>> f = isinstance(list1,g.Iterable)
>>> f
True
>>> from collections.abc import xxx
例如
from collections.abc import Iterator 检测是否是可迭代为什么不用typing模块from typing import Callable, Iterable, Iterator kogawananari 发表于 2021-5-31 12:33
检测是否是可迭代为什么不用typing模块from typing import Callable, Iterable, Iterator
谢谢解答,我刚学到魔法方法那章,还在学{:10_254:}
页:
[1]