import os.path if os.path.exists('filename.txt'): print ("File exist") else: print ("File not exist")
import os if not os.path.exists(path): with open(path, 'w'):
import os if not os.path.exists("PATH"): with open("PATH", "w"): pass