首页 > 编程语言 > 详细

python 字典与json 格式的相互转化

时间:2021-08-17 20:26:38      阅读:20      评论:0      收藏:0      [点我收藏+]
1、在python表示 假---False ; 在 json 假---false
2、在python表示 空---None;  在json    空 null
# json 转化为字典
import json
str1 = ‘{"info":false}‘
str11 = json.loads(str1)
print(str11,type(str11)) #{‘info‘: False} <class ‘dict‘>

# 字典转json
str2= {"info":None}
str3 = json.dumps(str2)
print(str3,type(str3)) #{"info": null} <class ‘str‘>

python 字典与json 格式的相互转化

原文:https://www.cnblogs.com/xiong-hua/p/15152708.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!