Open Python json file - if the file does not exist

Asked 2 years ago, Updated 2 years ago, 44 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


© 2024 OneMinuteCode. All rights reserved.