📜  在 django 中不使用相对路径读取 json - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:57.248000             🧑  作者: Mango

代码示例1
"""
So let's say you want to import a JSON file that you have in your
local (Django Project) you can use this rather than using a relative
path which can give you some issues.
"""

import importlib

json_text = importlib.resources.read_text('app.folder_name', 'file_name.json')