If you get it with REST, JSON will receive the following results:
I would like to substitute the "abcde"
of result1
and "efghi"
of result2
for variables, but I don't know how to do it.
{
"code": null,
"reason"—null,
"params": {
"result1": "abcde",
"result2": "efghi"
},
"result"—true,
"error"—Null
}
Can someone teach me how to do it?
python
For example, if you use the requests module to do response=requests.get(), the result can be obtained with response.json(), and the value is list or dict.All you have to do is change the value by normal operation.
sample code
import requests
# Example of placing test.json in the current directory with the following command and setting up a simple server:
# >python-m http.server8000
url="http://localhost:8000/test.json"
resp=requests.get(url)
params=resp.json() ["params" ]
result1 = param ["result1" ]
result2=params ["result2"]
print(result1,result2)
#abcdeefghi
This post is based on @KenjiNoguchi's Comments and so on, and then posted as Community WikiI wrote it.
This post is based on @KenjiNoguchi's Comments and will be posted as Community WikiYes.
© 2024 OneMinuteCode. All rights reserved.