示例如下:
import json
"""
当进行预期和时间结果比对是,有些参数结果为null,但是python语言是不认识null的,只认识None
,所以,要进行转换;
"""
ss = '{"user":"python","passwd":"123456","check":null}'
# json字符串转换成字典
ss_dict = json.loads(ss)
print(ss_dict)
print(type(ss_dict))
ss2 ={'user': 'python', 'passwd': '123456', 'check': None}
# 将字典转换成json字符串
ss_str = json.dumps(ss2,ensure_ascii=False) #如果参数是汉字,不添加ensure_ascii=False,则输出为乱码;
print(ss2)
print(type(ss_str))
----粘图---
标签:load,dump,ss,python,json,dict,print,null From: https://www.cnblogs.com/suhongzhen/p/16966530.html