Binary Response Content

You can also access the response body as bytes, for non-text requests:

  1. >>> r.content
  2. b'[{"repository":{"open_issues":0,"url":"https://github.com/...

The gzip and deflate transfer-encodings are automatically decoded for you.

For example, to create an image from binary data returned by a request, you can use the following code:

  1. >>> from PIL import Image
  2. >>> from StringIO import StringIO
  3. >>> i = Image.open(StringIO(r.content))