When dealing with requests
we are mostly interested in the content we receive. In this lesson you’ll learn how to access the response content as well as the response meta information stored in the headers.
You can access the content of a response in three different ways and formats. Here is a quick overview about the different ways and formats:
content
: This attribute returns the raw bytes of the response contenttext
: Thetext
attribute returns the content as a normal UTF-8 encoded Python stringjson()
: You can use thejson()
method to get the response content in JSON format
The headers
attributes returns a Python dictionary with all of the response headers.
Stephen Paden on June 25, 2019
I am learning SO much about Python, VIM, and now bpython. RealPython is literally the best site I have ever learned from. It’s increasing my workflow productivity.