Created
September 13, 2022 16:30
-
-
Save ycaty/26e4a4526b548d00ecb4ae1b1f8fd142 to your computer and use it in GitHub Desktop.
print colorful json
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
from pygments import highlight | |
from pygments.formatters.terminal import TerminalFormatter | |
from pygments.lexers.web import JsonLexer | |
dict = {'123':{'cats':6,'dogs':0}} | |
raw_json = json.dumps(dict , indent=4) | |
colorful_json = highlight( | |
raw_json, | |
lexer=JsonLexer(), | |
formatter=TerminalFormatter(), | |
) | |
print(colorful_json) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment