Quantcast
Channel: How do I check whether a file exists without exceptions? - Stack Overflow
Viewing all articles
Browse latest Browse all 46

Answer by Devbrat Shukla for How do I check whether a file exists without exceptions?

$
0
0

Use os.path.exists() to check whether file exists or not:

def fileAtLocation(filename,path):    return os.path.exists(path + filename)filename="dummy.txt"path = "/home/ie/SachinSaga/scripts/subscription_unit_reader_file/"if fileAtLocation(filename,path):   print('file found at location..')else:   print('file not found at location..')

Viewing all articles
Browse latest Browse all 46

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>