Contact: aviboots(AT)netvision.net.il
39,855 questions
51,776 answers
573 users
import os.path filename = "d:\data.txt" if os.path.isfile(filename): print("file exist") else: print("file not exist") ''' run: file exist '''
from pathlib import Path filename = "d:\data.txt" f = Path(filename) if f.is_file(): print("file exist") else: print("file not exist") ''' run: file exist '''
import os.path file = "d:\data.txt" if os.path.exists(file): print("file exist") else: print("file not exist") ''' run: file exist '''