Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何将 JSON 文件的所有内容加载到我的项目中?我使用 Python-Django 作为我的后端,使用 MongoDB 作为我的数据库。我正在尝试将 JSON 文件的内容存储到 MongoDB (Djongo)
尝试:
import os import json from django.core.files.storage import default_storage path = 'path/to/file.json' default_storage.open(path).read() # You may have to decode from Bytes to utf-8 # If you need to parse it to an array: json = json.loads(data)