You can use the os module:
Like this By os.path.isfile():
import os.path
os.path.isfile(file_path)
Or Using os.path.exists():
if os.path.exists(file_name): print("I get the file >hubaa")
if the file doesn't exist :(return False)
if not os.path.exists(file_name):
print("The File s% it's not created "%file_name)
os.touch(file_name)
print("The file s% has been Created ..."%file_name)
And you can write a simple code based on (try,Except):
try:
my_file = open(file_name)
except IOError:
os.touch(file_name)