Prettify Your Data Structures With Pretty Print in Python
The Python pprint
module is helpful in many situations.
It comes in handy when making API requests,
dealing with JSON files,
or handling complicated and nested data.
You’ll probably find that using the normal
print()
function
isn’t adequate to efficiently explore your data
and debug
your application.
When you use print()
with dictionaries
and lists,
the output doesn’t contain any newlines.
Before you start exploring pprint
,
you’ll first use urllib
to make a request to get some data.
You’ll make a request to
{JSON} Placeholder
for some mock user information.
The first thing to do is to make the HTTP GET
request
and put the response into a dictionary: