json - 使用 django python 读取 json 文件
问题描述
我有一个 json 文件。我想在 django python 中读取 json 文件。
Json 文件包含
{
"ATM Cash" : ["withdrawal"],
"Expense" :["fees","goods","stationery","purchase","material","telephone"],
"Income" : ["salary","deposit","rewards"],
"Payment" : ["tranfer","payment"],
"Medical" : ["dr ",
"doctor","dr.","nursing","pharmacist","physician","hospital","medicine"],
"Food/Restaurent" :["food","catering"],
"Groceries" : ["big bazar"],
"Shopping" : ["cloths"],
"Mobile recharge" : ["airtel"],
"Auto & Fuel" : ["fuel"],
"Travel" : ["travel"],
"General" : ["others"]
}
解决方案
如果它是一个文件,那么使用json.load()
like
import json
with open('path/to/file/file_name.json', 'r') as f:
my_json_obj = json.load(f)
推荐阅读
- firebase - Flutter Firebase 登录错误但仍在登录?
- python - 如何使用 Replit Database 为一个键存储两个值
- node.js - 与nodejs服务器反应本机应用程序中的网络错误
- c# - 我可以在其他窗口的主窗口中使用相同的连接吗?C# wpf mysql
- node.js - 我无法在 WebStorm 中使用调试器并出现错误(节点:12356)
- html - 选择选项中的平面图标
- c++ - 在 C++ 中导入头文件
- angular - Angular Material - mat-select 无故停止工作
- jdbc - 如何遍历结果集并打印到从 beanshell 采样器触发的 JDBC 请求的控制台
- powershell - PowerShell (Get-ChildItem).Length 错误