2.1FTP的简单传输

Posted 啊峰哥

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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)

 

以上是关于2.1FTP的简单传输的主要内容,如果未能解决你的问题,请参考以下文章