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 202 views
202 views asked Jul 7, 2014 by avibootz
1 answer 162 views
1 answer 172 views
2 answers 192 views
1 answer 180 views
...