How can I get current working directory of FTP using python?
I have the following code and wanted to store file names into the list in the root directory.
from ftplib import FTP
ftp = FTP('domainname.com')
ftp.login(user='username',passwd = 'password')
You can use ftp.pwd
to get current working dir.
Ex:
from ftplib import FTP
ftp = FTP('domainname.com')
ftp.login(user='username',passwd = 'password')
ftp.pwd() #Current working dir
ftp.cwd("Destination_Path") #To change to a different path
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.