【发布时间】:2021-07-15 06:48:09
【问题描述】:
Python 3.7.1 上的 Timeseries 包出现此错误
from types import IntType, LongType, DictType
ImportError: cannot import name 'IntType' from 'types'
有人对此有解决方案吗?
【问题讨论】:
标签: python types import package lib
Python 3.7.1 上的 Timeseries 包出现此错误
from types import IntType, LongType, DictType
ImportError: cannot import name 'IntType' from 'types'
有人对此有解决方案吗?
【问题讨论】:
标签: python types import package lib
您导入的 3 个方法 (IntType, LongType, DictType) 不存在。
>>> import types
>>> dir(types)
['AsyncGeneratorType', 'BuiltinFunctionType', 'BuiltinMethodType', 'CodeType', 'CoroutineType', 'DynamicClassAttribute', 'FrameType', 'FunctionType', 'GeneratorType', 'GetSetDescriptorType', 'LambdaType', 'MappingProxyType', 'MemberDescriptorType', 'MethodType', 'ModuleType', 'SimpleNamespace', 'TracebackType', '_GeneratorWrapper', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_ag', '_calculate_meta', '_collections_abc', '_functools', 'coroutine', 'new_class', 'prepare_class']
>>>
如您所见,这 3 个都不在列表中。
【讨论】:
我相信types 模块(不再)不再提供所有可以通过内置命名空间访问的类型。您可以简单地使用纯 python 中的int 或dict。
【讨论】: