windows python 访问ftp

来源:互联网 发布:php商城系统 编辑:程序博客网 时间:2024/05/17 22:47

在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()

 

原创粉丝点击