分享一段python代码,引入ftplib模块,实现ftp方式发送文件的代码示例。
代码如下:
 
复制代码 代码示例:
import ftplib                                          # We import the FTP module
session = ftplib.FTP('myserver.com','login','passord') # Connect to the FTP server
myfile = open('toto.txt','rb')                         # Open the file to send
session.storbinary('STOR toto.txt', myfile)            # Send the file
myfile.close()                                         # Close the file
session.quit()