将字典写入json文件


data_dict = {'150245': {'name': '存在', 'class': '1', 'cvedate': '2013-01-17', 'type': '202', 'sid': '150245', 'action': '1'}, '150905': {'name': '本地文件', 'class': '1', 'cvedate': '', 'type': '901', 'sid': '150905', 'action': '1', }}

json_str = json.dumps(data_dict, ensure_ascii=False, indent=4)  // ensure_ascii=False(输出中文), indent=4(缩进为4)

with open('new_pvs_library4.json', 'w', encoding='utf-8') as f:
f.write(json_str)


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM