Check if file or directory exist
-
Hello,
How can i check if file or directory exist as /sd for example? It does not work with :os.path.isfile(filename)
-
The most pythonish way is to assume that the file file or directory exists. A simple approach could be:
try: os.stat(filename) #if here file or dir exists except: #if here file or dir does not exist
-
Try
os.stat(path)
oros.listdir([dir])