How to check if file exist in Python

1 Answer

0 votes
from os import path

if path.exists("d:\data.txt"):
    print("File exists")
else:
    print("File not found")

'''
run:

File exists

'''

 



answered Nov 12, 2018 by avibootz

Related questions

1 answer 214 views
214 views asked Jul 7, 2014 by avibootz
1 answer 170 views
1 answer 187 views
2 answers 206 views
1 answer 191 views
...