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 294 views
294 views asked Jul 7, 2014 by avibootz
1 answer 250 views
1 answer 296 views
2 answers 310 views
1 answer 282 views
...