Python pprint – pretty-print data structures


Python tip:

You can use pprint.pprint to print a formatted representation of an object.

For example:

import json
import pprint
from urllib.request import urlopen

with urlopen("https://pypi.org/pypi/flask/json") as resp:
    project_info = json.load(resp)["info"]

pprint.pprint(project_info)

"""
{'author': 'Armin Ronacher',
 'author_email': '[email protected]',
 'bugtrack_url': None,

 ...

 'requires_python': '>=3.6',
 'summary': 'A simple framework for building complex web applications.',
 'version': '2.0.1',
 'yanked': False,
 'yanked_reason': None}
"""