简体   繁体   中英

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. How can I access the subdirectories?

Try this

s.listdir(remotepath=folderlist[0])

folderlist[0] is a string.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM