python json.loads()字符串转json
import json
import requests
res = '''{"code":200,"message":"success","duration":147,"result":{"angle":0,"height":368,"tables":[],"width":500},"version":"v2.0.0"}'''
json_obj = json.loads(res)
print(type(json_obj))
print(json_obj['result'])
print(json_obj['result']['height'])
url = "https://www.ycpai.cn/other/AddVisit.do"
res = requests.get(url)
print(type(res))
print(res.text)
print(type(res.text))
json_obj = json.loads(res.text)
print(json_obj)
print(type(json_obj))
print(json_obj['resultCode'])
json_string = '{"key1":"value1","key2":"value2","key3":"value3"}'
data = json.loads(json_string)
for key in data:
value = data[key]
print(f"key:{key}, value:{value}")