Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python json serialize print pretty

pretty_print_json = pprint.pformat(json_data).replace("'", '"')

with open('file_name.json', 'w') as f:
    f.write(pretty_print_json)
Comment

python json serialize print pretty

import json

def pp_json(json_thing, sort=True, indents=4):
    if type(json_thing) is str:
        print(json.dumps(json.loads(json_thing), sort_keys=sort, indent=indents))
    else:
        print(json.dumps(json_thing, sort_keys=sort, indent=indents))
    return None

pp_json(your_json_string_or_dict)
Comment

PREVIOUS NEXT
Code Example
Python :: max index tuple 
Python :: retinaface detection 
Python :: python __sub__ 
Python :: Python how to use __sub__ 
Python :: __le__ 
Python :: modles en django 
Python :: NumPy rot90 Example Rotating Three times 
Python :: selenium rotate user agent 
Python :: make all subplots same height 
Python :: NumPy bitwise_xor Code When inputs are Boolean 
Python :: pymenu template 
Python :: main code for bpsk scheme 
Python :: turn dictionary into flat list 
Python :: how to calculate iqr in pandas 
Python :: Remove Brackets from List Using join method 
Python :: list python !g 
Python :: SQL Query results in tkinter 
Python :: python random number between 1000 and 9999 
Python :: how to Capture only the ICMP packet. using bpf 
Python :: problème barbier semaphore python 
Python :: How to secure an endpoint for selected users with Flask-JWT-Extended 
Python :: singke line expresions python 
Python :: dataframe missing and zero values 
Python :: how to close python in terminal 
Python :: found django install path 
Python :: ring create an application to ask the user about his/her name. 
Python :: Uso de lambda 
Python :: python 2nd order ode 
Python :: colorgram.py 1.2.0 
Python :: Rebinding a list stored in a Flask Session 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =