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

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'>
posted @ 2021-08-17 15:58  大熊童鞋  阅读(683)  评论(0编辑  收藏  举报