« Back to Index

Pretty Print Dictionary

View original Gist on GitHub

Tags: #python

python pretty print dictionary.py

import json

print(json.dumps({"foo": {"bar": {"baz": 123}}}, indent=2, default=str))

# outputs...
{
  "foo": {
    "bar": {
      "baz": 123
    }
  }
}