【问题标题】:ImportError: cannot import name 'IntType' from 'types'ImportError:无法从“类型”导入名称“IntType”
【发布时间】: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


    【解决方案1】:

    您导入的 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 个都不在列表中。

    【讨论】:

      【解决方案2】:

      我相信types 模块(不再)不再提供所有可以通过内置命名空间访问的类型。您可以简单地使用纯 python 中的intdict

      【讨论】:

        猜你喜欢
        • 2019-03-10
        • 1970-01-01
        • 1970-01-01
        • 2016-05-29
        • 2018-12-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多