“Python Json Serialize Print Pretty Pretty” Kode Jawaban

Python Json Serialize Print Pretty Pretty

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

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

Python Json Serialize Print Pretty 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)
DreamCoder

Jawaban yang mirip dengan “Python Json Serialize Print Pretty Pretty”

Pertanyaan yang mirip dengan “Python Json Serialize Print Pretty Pretty”

Lebih banyak jawaban terkait untuk “Python Json Serialize Print Pretty Pretty” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya