How to use pprint to print a dictionary on multiple lines in Python

1 Answer

0 votes
import pprint

dic = {'a':11, 'b':22, 'c':33, 'ww': {1:1, 2:2, 3:3}}

pprint.pprint(dic, width=1)



'''
run:

{'a': 11,
 'b': 22,
 'c': 33,
 'ww': {1: 1,
        2: 2,
        3: 3}}

'''

 



answered May 25, 2019 by avibootz

Related questions

1 answer 163 views
3 answers 277 views
2 answers 160 views
2 answers 256 views
1 answer 228 views
2 answers 232 views
...