Python2.7 将字典转json格式入库

Python2.7 将字典转json格式入库

1、代码示例:

复制代码
import json
 
developer = {
    "name": "admin",
    "salary": 9000,
    "skills": ["Raspberry pi", "Machine Learning", "Web Development"],
    "email": "admin@webkaka.com"
}
 
with open("developerPrettyPrint.json", "w") as write_file:
    # json.dump(developerPrettyPrint, write_file)
    json.dump(developer, write_file, indent=4, separators=(", ", ": "), sort_keys=True)
print("Done writing pretty printed JSON data into a file")
复制代码

2、输出结果

 

posted @   整合侠  阅读(34)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2018-06-01 Python3.x:获取登录界面校验码图片
点击右上角即可分享
微信分享提示