1 import json 2 3 data = { 4 "statusCode": 0, 5 "data": { 6 "totoal": "5", 7 "height": "5.97", 8 "weight": "10.30", 9 "age": "3" 10 }, 11 "msg": "成功" 12 } 13 14 #dumps:把字典转换为json字符串 15 s = json.dumps(data) 16 print s 17 18 #loads:把json转换为dict 19 s1 = json.loads(s) 20 print s1 21 22 print s1["statusCode"] 23 24 print s1["data"]["age"]
时间: 2024-11-08 13:26:31