使用python解析Json字符串-获取Json字符串关键字

import json

data = {
	"statusCode": 200,
	"data": {
		"totoal": "5",
		"height": "5.97",
		"weight": "10.30",
		"age": "11"
	},
	"msg": "成功"
}

#dumps:把字典转换为json字符串
s = json.dumps(data)
print s

#loads:把json转换为dict
s1 = json.loads(s)
print s1
#打印statusCode对应的值
print s1["statusCode"]

#打印data下age对应的值
print s1["data"]["age"] 

你可能感兴趣的:(接口测试,Python)