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

来源:互联网 发布:p2p网络借贷新闻 编辑:程序博客网 时间:2024/06/07 06:21

判断目录是否为:目录:

os.path.isdir(path)Return True if path is an existing directory. This follows symbolic links, so both islink() andisdir() 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() andisfile() 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 arenot supported.




0 0