Function to Print a nicely formatted Dictionary or List?

Larry Martell larry.martell at gmail.com
Thu Jun 9 13:47:42 EDT 2022


On Thu, Jun 9, 2022 at 11:44 AM 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!

>>> import json
>>> d = {'John': 'Cleese', 'Eric': "Idle", 'Micheal': 'Palin'}
>>> print(json.dumps(d, indent=4))
{
    "John": "Cleese",
    "Eric": "Idle",
    "Micheal": "Palin"
}


More information about the Python-list mailing list