pyhton 判断文件 或 目录是否存在

判断目录是否为:目录:

os.path.isdir(path)
Return True if path is an existing directory. This follows symbolic links, so both islink() and
isdir() can be true for the same path.

判断目录是否为:文件:

os.path.isfile(path)
Return True if path is an existing regular file. This follows symbolic links, so both islink() and
isfile() can be true for the same path.

判断目录是否为:符号链接:

os.path.islink(path)
Return True if path refers to a directory entry that is a symbolic link. Always False if symbolic links are
not supported.




你可能感兴趣的:(python,Path)