2
[Python] Pretty Print Variable (Dictionary, List, Object, Array)
source link: https://siongui.github.io/2013/03/09/python-pretty-print-variable/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
[Python] Pretty Print Variable (Dictionary, List, Object, Array)
March 09, 2013The easiest way is through json module included in Python:
print(json.dumps(obj, sort_keys=True, indent=4, separators=(',', ': ')))
where obj is your variable, could be dictionary (equivalent to object in JavaScript) or list (equivalent to array in JavaScript).
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK