python判断目录(python检测给定的路径是否存在的方法)
导读:os.path 模块提供了函数用于检测给定的路径是否存在...
os.path 模块提供了函数用于检测给定的路径是否存在
1 、path 参数所指的文件或文件夹存在 ,调用os.path.exists(path) 返回 True ,否则返回 False
>>>os.path.exists(C:\\Windows) True >>>os.path.exists(C:\\Win) False2 、path 参数存在并且是一个文件 ,调用 os.path.isfile(path) 返回 True ,否则返回 False
>>>os.path.isfile(C:\\Windows\\System32) False >>>os.path.isfile(C:\\Windows\\System32\\C_20280.NLS) True >>>os.path.isdir(C:\\Windows\\System32\\C_20280.NLS) False >>>os.path.isdir(C:\\Windows\\System32) True创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!