2.1FTP的简单传输

第一个简单的FTP传输实例

from ftplib import FTP

nonpassive = False
filename = 'new_1.py'
dirname = '.'
sitename = '192.168.191.1' #连接FTP服务器地址
#如果设置密码
#userinfo = ('username','password')
#如果没有设置帐号密码userinfo = () print('Connecting...')
connection = FTP(sitename)
connection.login(*userinfo)
connection.cwd(dirname)
if nonpassive: #force active FTP if server requires
connection.set_pasv(False) print('Downloading...')
localfile = open(filename,'wb')
connection.retrbinary('RETR '+filename,localfile.write,1024)
connection.quit()
localfile.close()
print('Finished')
上一篇:SpringBoot系列: 与Spring Rest服务交互数据


下一篇:dll导入导出宏定义,出现“不允许 dllimport 函数 的定义”的问题分析