json是一种轻量级数据交换格式,常用于http请求中,在日常运维工作中经常可以看到
1.json类型和python数据的转换
函数转换对应关系表:
Python JSON
dict object
list...2)读取文件中json数据,显示为unicode类型格式:json.load()
import json
# json_data = {"a":1,"b":2,"c":3,"d":4,"e":5,"f...(f2)
print(dict2)
结果:
{u'a': 1, u'c': 3, u'b': 2, u'e': 5, u'd': 4, u'f': 6}
3)python字典—>(转换)json字符串:...json.dumps()
例子:
import json
m = {"success":"yes","message":"hello"}
json_str = json.dumps(m)
print(m...type(json_str))
json_dict = json.loads(json_str)
print(json_dict)
print(type(json_dict))
结果:
{"message