python - 导入被另一个同名包覆盖的默认 python 包

标签 python

我正在与一个图书馆合作,他们认为创建一个名为 json 的模块是个好主意,它与标准 json 模块完全不同

有没有办法导入默认的json模块?

最佳答案

在py2中你可以使用绝对导入

from __future__ import absolute_import
import json #this imports standard lib json
import mypackage.json as my_json #import custom json module

关于python - 导入被另一个同名包覆盖的默认 python 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28485913/

相关文章:

python - "TypeError: ' NoneType ' object is not iterable"来自 pandas read_sql

Python 更新类变量

python - 如何在对图中显示分类数据框

python - 仅当给出可选部分时,Docopt 才会继续

python - 在 Python 中管理(即正确终止)MongoDB 守护进程最可接受的方法是什么?

python - 如何跨类重用函数

python - 如何使用 Python 更新 JSON 文件?

python - PyEphem 中的 .parallctic_angle() 方法

python - 使用 Python 写入文件 -- '' 虽然未完成 :"Confusing Me

python - if、elif、else 条件