Function to Print a nicely formatted Dictionary or List?

Mats Wichmann mats at wichmann.us
Thu Jun 9 15:01:16 EDT 2022


On 6/9/22 11:52, Chris Angelico wrote:
> On 2022年6月10日 at 03:44, Dave <dave at looktowindward.com> wrote:
>>>> Hi,
>>>> Before I write my own I wondering if anyone knows of a function that will print a nicely formatted dictionary?
>>>> By nicely formatted I mean not all on one line!
>>>> https://docs.python.org/3/library/pprint.html
>> from pprint import pprint
> pprint(thing)
>> ChrisA

I might add the note that there was a recent thread on the Discuss board
about options for styling the pprint output (okay, it was me that
started that one...) - you can choose indent and compact (compact is the
not-all-on-one-line flag) but there might be some other choices missing.
haven't gotten around to following up on that...
https://discuss.python.org/t/pprint-styling-options/15947


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /