Open Python json file - if the file does not exist

Asked 2 weeks ago, Updated 2 weeks ago, 1 views

I will open the json file in Pysun, but if there is no file, I would like to inform you that there is no file through the print statement What should I write in this case?

json python

2022-09-20 11:18

2 Answers

Check if it exists as os.path.exists,


2022-09-20 11:18

This is how I do this.

try:
    json open
except:
    print()


2022-09-20 11:18

If you have any answers or tips


© 2022 pinfo. All rights reserved.