Read JSON file and Pretty-Print it to another file

后端 未结 2 527
梦毁少年i
梦毁少年i 2021-01-27 07:30

I have a complex (nested) json text file that is one long line in the text file

Is there any way to read in the file (in python) and indent / pretty-print the json to a

2条回答
  •  春和景丽
    2021-01-27 07:47

    Yes, you can use open() to read/write file, then json.load() to read the file and json.dump(..., indent=4) to pretty-print it.

提交回复
热议问题