python - 无法在 Python 2.7 或 Python 3.3 中导入小数

标签 python python-2.7 python-3.x

我无法在 Python 2.7 或 3.3 的终端中导入小数

这是我得到的错误:

Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 01:25:11) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import decimal
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/decimal.py", line 3849, in <module>
    _numbers.Number.register(Decimal)
AttributeError: 'module' object has no attribute 'Number'

或 Python 2.7

Python 2.7.2 (default, Oct 11 2012, 20:14:37) 
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import decimal
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/decimal.py", line 141, in <module>
    import numbers as _numbers
  File "numbers.py", line 34, in <module>
    assert x / y == 2.5 # true division of x by y
AssertionError

如何导入小数?

最佳答案

当前工作目录下有numbers.py吗?

这可能是问题的原因,因为这阻止了标准库模块的导入 numbers .

关于python - 无法在 Python 2.7 或 Python 3.3 中导入小数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18045299/

相关文章:

python - create() 需要 1 个位置参数但给出了 2 个?

python-2.7 - 如何从 matplotlib 向 FuncAnimation 添加时间控制面板

python - 从另一个列表中删除列表列表

regex - python正则表达式-列表中的re.findall()

python-3.x - 如何在 RaspBerry Pi 3 Model B 上安装 Anaconda

Python Dict 多个 Max 值

python - 将两个不同长度的数据帧的列相加

python - 需要刷新 Python 多处理队列

python - 计算迭代器的产量数?

python strip 剥离的内容超出了要求