How to check whether a file exists or not without exceptions in python ?

It is easy to check whether a file exists or not without exceptions in python ,python has a familiar os.path module using this module you can run isfile ,if it return True means a file exists or if it is False means file not exists

Code to check whether a file exists or not without exceptions in python


import os.path
os.path.isfile(FILE_PATH)


e.g 

>>> os.path.isfile("/home/index.html")
True
>>> os.path.isfile("/home/index_new.html")
False

My Thought

Your email address will not be published. Required fields are marked *

Our Tool : hike percentage calculator