Use os.path.exists
to check both files and directories:
import os.path
os.path.exists(file_path)
Use os.path.isfile
to check only files
import os.path
os.path.isfile(file_path)
Use os.path.exists
to check both files and directories:
import os.path
os.path.exists(file_path)
Use os.path.isfile
to check only files
import os.path
os.path.isfile(file_path)