2024-04-26 09:20:03 发布
网友
我试图用Python列出一个Synology NAS上的所有共享文件夹。在
假设我想要一个\\DISKSTATION上每个文件夹的列表 例如:公共、家庭、电影等
有可能吗?在
谢谢你的帮助!在
from smb.SMBConnection import SMBConnection conn = SMBConnection('username', 'password', 'local_NetBIOS_name', 'remote_NetBIOS_name') conn.connect('domain address') folders = conn.listPath('share_name', '/relative/subfolder') for folder in folders: print folder.filename
在连接也可以利用域地址xyz.com网站在
如果您可以直接访问NAS文件夹(无需进一步验证),则可以尝试运行python:
import os os.listdir(r'\\DISKSTATION')
它将打印出\\DISKSTATION中的子文件夹。如果你想找到所有的子文件夹,你可以按照:Getting a list of all subdirectories in the current directory
\\DISKSTATION
为什么不使用pysmb?在
pysmb
pip install pysmb
要列出共享内容:
将输出:
. .. dir1 dir2 file1 file2
在连接也可以利用域地址xyz.com网站在
^{pr2}$如果您可以直接访问NAS文件夹(无需进一步验证),则可以尝试运行python:
它将打印出
\\DISKSTATION
中的子文件夹。如果你想找到所有的子文件夹,你可以按照:Getting a list of all subdirectories in the current directory为什么不使用
pysmb
?在要列出共享内容:
^{pr2}$将输出:
相关问题 更多 >
编程相关推荐