Last active
October 17, 2017 05:03
-
-
Save jatinkrmalik/cc64a3230459a83199c8b0e5806e9960 to your computer and use it in GitHub Desktop.
Pretty print python3 dictionary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
def prettyPrint(dct): | |
print(json.dumps(dct, indent=4, sort_keys=True)) | |
if __name__ == "__main__": | |
sample = {'name':'Jatin K Malik', 'age':25, 'id':1299, 'address':'Delhi, India', 'phone':9999999999, 'hobbies':'Code'} | |
prettyPrint(sample) | |
##################### | |
#Output: | |
#{ | |
# "address": "Delhi, India", | |
# "age": 25, | |
# "hobbies": "Code", | |
# "id": 1299, | |
# "name": "Jatin K Malik", | |
# "phone": 9999999999 | |
#} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment