import requests
r = requests.get('test.com')
x=r.json()
print(x)
output is
{"test1":858,"test1":154343,"test":106091}
but x's type is str
, how to get key,value
from x ? i want to get only 858
import requests
r = requests.get('test.com')
x=r.json()
print(x)
output is
{"test1":858,"test1":154343,"test":106091}
but x's type is str
, how to get key,value
from x ? i want to get only 858
The json
function turns the response to a Python dict
essentially, so you can use the keys()
function or enum unpacking to get the keys and from there obtain the values.