在windows下python访问ftp
from ftplib import FTP
import time
if __name__=='__main__':
ftp=FTP()
ftp.connect('192.168.4.152','21')
ftp.login('ftpuser','ftpuser')
print ftp.getwelcome()
ftp.cwd('demonstrate') #set the current of the directory
ftp.dir()
buffersize=1024
filename='1.txt'
file=open(filename,'wb')
file_handler=file.write
ftp.retrbinary('RETR 1.txt',file_handler,buffersize)
print 'download completely'
file.close()
ftp.quit()
本文介绍如何使用Python在Windows环境下连接并操作FTP服务器。通过示例代码演示了连接FTP服务器、下载文件等基本操作。
2801

被折叠的 条评论
为什么被折叠?



