1import os
2
3os.path.exists("file.txt") # Or folder, will return true or false
1import os.path
2
3if os.path.isfile('filename.txt'):
4 print ("File exist")
5else:
6 print ("File not exist")
7
1import os
2filename = "creating file with python function"#your file name
3print("Do ",filename," exists:- ",os.path.exists(filename))