Function to Print a nicely formatted Dictionary or List?
Dave
dave at looktowindward.com
Thu Jun 9 15:35:24 EDT 2022
Hi,
I quite like the format that JSON gives - thanks a lot!
Cheers
Dave
> On 9 Jun 2022, at 20:02, Stefan Ram <ram at zedat.fu-berlin.de> wrote:
>
> Since nicety is in the eyes of the beholder, I would not
> hesitate to write a custom function in this case. Python
> has the standard modules "pprint" and "json".
>
> main.py
>
> import json
> d ={ 1:2, 'alpha': 'beta' }
> print( json.dumps( d, indent=4 ))
>
> output
>
> {
> "1": 2,
> "alpha": "beta"
> }
>
More information about the Python-list
mailing list