pprint dictionary on multiple lines
Use width=1
or width=-1
:
In [33]: pprint.pprint(a, width=1){'first': 123, 'second': 456, 'third': {1: 1, 2: 2}}
You could convert the dict to json through json.dumps(d, indent=4)
print(json.dumps(item, indent=4)){ "second": 456, "third": { "1": 1, "2": 2 }, "first": 123}
If you are trying to pretty print the environment variables, use:
pprint.pprint(dict(os.environ), width=1)