首先声明我用的是python3.版本,登陆远程FTP服务器的话,需要获得权限,
-- coding: utf-8 --
import ftplib;
ftp = ftplib.FTP()
host ='1XXXXX'
userName='administrator'
passWord ='12345678'
port = 21
timeout = 100
ftp.connect(host, port, timeout)
ftp.login(userName, passWord)
ftp.encoding='gb18030'
//列举出远程FTP下的文件夹的名字
allFileName = ftp.nlst()
for lists in allFileName:
print (lists);