2024-10-01 02:29:28 发布
网友
当我在脚本中执行以下行时:
if os.path.exists('/home/jsc0606/Desktop/project/myfile.py')
我得到False。但是,当我在终端的同一个目录中执行同一行时,我得到True。有人知道为什么Python在执行脚本中的那一行时找不到文件吗?在
False
True
如the docs关于os.path.exists所述:
os.path.exists
On some platforms, this function may return False if permission is not granted to execute os.stat() on the requested file, even if the path physically exists.
os.stat()
我认为可能是这样的:您可能是以不同的权限运行脚本。在
如the docs关于
os.path.exists
所述:我认为可能是这样的:您可能是以不同的权限运行脚本。在
相关问题 更多 >
编程相关推荐