Python OS.path.exists 无法从本地主机工作


python os.path.exists not working from localhost

我正在从php文件运行python脚本。在python脚本中,我必须检查是否存在文件夹。装载位置中的文件夹。如果我检查 os.path.exists 不起作用。下面是我的示例代码。

mount_smbfs //user1:1234@system1/Apps/PublishAssets ~/z

在 Python 中,我正在以这样一种方式进行检查.

os.path.exists('/Volumes/PublishAssets')

我正在从本地主机运行 PHP。

http://localhost/~user1/Apps/index.php

我总是得到不存在的文件夹。但物理上能够看到文件夹和文件夹内容。

请帮助我找到正确的道路。提前谢谢。

您可以通过两种方式执行此操作(不过只选择一种):

将装入点更改为/Volumes/PublishAssets

(异

更改 Python 中指定的路径:

# os.path.exists('/Volumes/PublishAssets')
# replace with
os.path.exists(os.path.expanduser('~/z'))

确保运行脚本的用户对挂载的文件系统具有权限

要使用权限进行装载:

mount_smbfs -f0777 -d0777 //user:pass@host/folder /target