import os
print(os.path.isdir("/home/el"))
print(os.path.exists("/home/el/myfile.txt"))
os.path.isdir returns True if a directory exists in the given path. Because isdir follows the symbolic link, both islink() and isdir() can return True for the same path
os.path.exists returns True
if a given path exists. Returns False
if the path is broken symbolic link
.
On some platforms, you can return False
if you cannot access the file with os.stat()
even if the path exists
© 2024 OneMinuteCode. All rights reserved.