How to Check if a File Exists in Python: Try/Except, Path, and IsFile
If we’re looking to check if a file exists, there are a few solutions:
Check if a file exists with a try/except block (Python 2+)
Check if a file exists using os.path (Python 2+)
Check if a file exists using the Path object (Python 3.4+)