S
S
Sergey Prokhorov2019-09-11 12:28:23
Python
Sergey Prokhorov, 2019-09-11 12:28:23

What are the options for a beautiful dictionary output to the console?

Does anyone know how to improve console output in pycharm? Now the dictionary is displayed in 1 line, is there an option to display it like a tree? Maybe some kind of plugin or a checkmark in the settings? Or using third-party libraries? Maybe I’m outputting it wrong at all? Now I’m outputting either exit or print

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yura Khlyan, 2019-09-11
@NeonTheOne

1.pprint 2
.

>>> 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
        }
    }
}

S
smsi, 2019-09-11
@smsi

from prpint import pprint
import json
pprint json.dumps({'a':2, 'b':{'x':3, 'y':{'t1': 4, 't2':5}}},
. ..sort_keys=True, indent=4)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question