I have a JSON file that contains text for my project. For my project, I want to give the user the option to restart it completely. This requires it to delete the contents of the JSON file. How would I do that using python?
Asked
Active
Viewed 172 times
0
-
Do you still want the file to be _valid JSON_ or just an empty file? Specifically, opening any file in write mode will empty it; doesn't matter if its JSON – OneCricketeer Jun 26 '21 at 23:58
-
I don’t want the file to be deleted, just all the contents of the file. – NewToPython Jun 27 '21 at 00:00
-
I never said the file would be deleted. – OneCricketeer Jun 27 '21 at 00:02
-
json_dumps with an empty object. Same way you saved the results. – Josh J Jun 27 '21 at 00:04