Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Responses: Content and Headers

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 content
  • text: The text attribute returns the content as a normal UTF-8 encoded Python string
  • json(): You can use the json() method to get the response content in JSON format

The headers attributes returns a Python dictionary with all of the response headers.

Comments & Discussion

Become a Member to join the conversation.