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 or suggestions on this Python print topic.

Note: IDE: PyCharm 2021.3.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

Discover more from Tutorial

Subscribe now to keep reading and get access to the full archive.

Continue reading