Reputation: 21
I am trying to print response from a post request in python. Response shall be print in list. I tried the below code but i only get status code 200. Need help to print response body as per screenshot below .
import requests
r = requests.get('URL')
print r.json
Upvotes: 1
Views: 20549
Reputation: 171
Patrick, I hope this code can help you:
import requests
import json
import pprint
r = requests.get('URL')
pprint.pprint(json.loads(r.content))
pprint is only to see the output, I guess the main point for you are the json.loads
and r.content
.
Best Regards!
Upvotes: 4