Answers for "requests library response"

1

create a response object in python

from requests.models import Response

the_response = Response()
the_response.code = "expired"
the_response.error_type = "expired"
the_response.status_code = 400
the_response._content = b'{ "key" : "a" }'

print(the_response.json())
Posted by: Guest on June-09-2020
6

python print return code of requests

>>> import requests
>>> r = requests.get('http://httpbin.org/status/404')
>>> r.status_code
404
Posted by: Guest on June-15-2020

Browse Popular Code Answers by Language