使用
ftplib,您可以这样编写:
import ftplibsession = ftplib.FTP('server.address.com','USERNAME','PASSWORD')file = open('kitten.jpg','rb') # file to sendsession.storbinary('STOR kitten.jpg', file) # send the filefile.close() # close file and FTPsession.quit()ftplib.FTP_TLS如果FTP主机需要TLS,请改用。
要检索它,可以使用
urllib.retrieve:
import urlliburllib.urlretrieve('ftp://server/path/to/file', 'file')编辑 :
要查找当前目录,请使用
FTP.pwd():
FTP.pwd():返回服务器上当前目录的路径名。
要更改目录,请使用
FTP.cwd(pathname):
FTP.cwd(pathname):设置服务器上的当前目录。



