gpt4 book ai didi

python - os.path.isdir() 在无法访问但存在的目录上返回 false

转载 作者:太空宇宙 更新时间:2023-11-03 13:31:21 24 4
gpt4 key购买 nike

假设我有这样的目录:

foo/bar/

barchmod 777foo 是 000。

当我调用 os.path.isdir('foo/bar') 时,它只返回 False,没有任何 Permission Denied Exception 或任何东西,为什么会这样?它不应该返回 True 吗?

最佳答案

如果您不是 root 用户,则无法访问 foo。因此,您无法检查 foo/bar 是否存在,它会返回 False,因为它找不到具有该名称的目录(因为它无法访问父目录)。

关于python - os.path.isdir() 在无法访问但存在的目录上返回 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46666941/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com