Skip to content

Python print response body | Example code

  • by

Simple use requests.get() method to get all body content and use response.json() to get JSON data.

Python print response body examples

Simple example code returned plenty of content.

import requests as requests

r = requests.get("http://www.google.com")
print(r.content)

Don’t forget to install and import the request module.

Python print response body

Print JSON content

import requests

# Making a get request
response = requests.get('https://api.github.com')

# print response
print(response)

# print json content
print(response.json())

Do comment if you have any doubts and suggestions on this Python print topic.

Note: IDE: PyCharm 2021.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.