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

时间:2021-08-17 20:26:38   收藏:0   阅读:13
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‘>

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

评论(0)
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!