Python pprint Module
Example
Pretty-print nested data in a readable way:
from pprint import pprint
data = {"users": [{"name": "Emil", "tags": ["admin", "editor"]}]}
pprint(data)
Try it Yourself »
Definition and Usage
The pprint module formats Python objects in a way that’s easier for humans to read.
Use it to print complex dicts and lists with indentation, limited width, and sorted keys.
Members
| Member | Description |
|---|---|
| isreadable() | Return whether an object’s representation is likely to be readable by eval(). |
| pformat() | Return a pretty-printed string for an object (does not print). |
| pp() | Print a compact representation to stdout (like pprint() but streamlined). |
| pprint() | Pretty-print an object to stdout. |
| PrettyPrinter | Class with methods for customizable pretty printing. |