xxxxxxxxxx
>>> import json
>>> print json.dumps({'a':2, 'b':{'x':3, 'y':{'t1': 4, 't2':5}}},
sort_keys=True, indent=4)
{
"a": 2,
"b": {
"x": 3,
"y": {
"t1": 4,
"t2": 5
}
}
}
xxxxxxxxxx
import pprint
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(mydict)
xxxxxxxxxx
import pprint
my_dict = {"name": "John", "age": 30, "city": "New York"}
pprint.pprint(my_dict)