[英]Get subfolders from pysftp Connection
I have an admin account where customers upload files in a subdirectory.我有一个管理员帐户,客户可以在其中上传子目录中的文件。
import pysftp as sftp
import os
cnopts = sftp.CnOpts()
cnopts.hostkeys = None
s = sftp.Connection(host=myHostname, username=myUsername, password=myPassword, cnopts=cnopts)
folderlist = s.listdir()
This gives me back the following array:这给了我以下数组:
['Customer_1', 'Customer_2', 'Customer_3', 'Customer_4']
folderlist[0].listdir()
does not work here. folderlist[0].listdir()
在这里不起作用。 How can I access the subdirectories?如何访问子目录?
Try this尝试这个
s.listdir(remotepath=folderlist[0])
folderlist[0] is a string. folderlist[0] 是一个字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.