擅长:python、mysql、java
<p>本地Python很好地支持FTP-SSL显式。设置连接后,可以使用所有标准的ftplib命令。更多信息请访问:
<a href="http://docs.python.org/2/library/ftplib.html#ftplib.FTP_TLS" rel="noreferrer">http://docs.python.org/2/library/ftplib.html#ftplib.FTP_TLS</a></p>
<p>以下是下载文件的基本示例:</p>
<pre><code>from ftplib import FTP_TLS
ftps = FTP_TLS('ftp.MySite.com')
ftps.login('testuser', 'testpass') # login anonymously before securing control channel
ftps.prot_p() # switch to secure data connection.. IMPORTANT! Otherwise, only the user and password is encrypted and not all the file data.
ftps.retrlines('LIST')
filename = 'remote_filename.bin'
print 'Opening local file ' + filename
myfile = open(filename, 'wb')
ftps.retrbinary('RETR %s' % filename, myfile.write)
ftps.close()
</code></pre>