windows python 訪問ftp

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

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章