久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

用于連接 FTP 并下載文件的 Python 2.5 腳本

Python 2.5 script to connect to FTP and download file(用于連接 FTP 并下載文件的 Python 2.5 腳本)
本文介紹了用于連接 FTP 并下載文件的 Python 2.5 腳本的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我確信這已經(jīng)解決了,但我似乎找不到類似的問答(新手)使用 Windows XP 和 Python 2.5,我正在嘗試使用腳本連接到 FTP 服務(wù)器并下載文件.它應(yīng)該很簡單,但是按照類似腳本的說明,我得到了錯誤:

I am sure this has been resolved before but I cannot seem to find a similar Q&A (newbie) Using Windows XP and Python 2.5, I m trying to use a script to connect to an FTP server and dowload files. It should be simple but following the instructions of similar scripts I get the errors:

ftp.login('USERNAME')
  File "C:Python25libftplib.py", line 373, in login
    if resp[0] == '3': resp = self.sendcmd('PASS ' + passwd)
  File "C:Python25libftplib.py", line 241, in sendcmd
    return self.getresp()
  File "C:Python25libftplib.py", line 216, in getresp
    raise error_perm, resp
error_perm: 530 User USERNAME cannot log in.

我使用的腳本是:

def handleDownload(block):
    file.write(block)
    print ".",

# Create an instance of the FTP object
# FTP('hostname', 'username', 'password')
ftp = FTP('servername')

print 'ftplib example'
# Log in to the server
print 'Logging in.'
# You can specify username and password here if you like:
ftp.login('USERNAME', 'password') 
#print ftp.login()

# This is the directory 
directory = '/GIS/test/data'
# Change to that directory.  
print 'Changing to ' + directory
ftp.cwd(directory)

# Print the contents of the directory
ftp.retrlines('LIST')

我很欣賞這可能是一個微不足道的問題,但如果有人能提供一些見解,那將非常有幫助!

I appreciate this might be a trivial question, but if anyone can provide some insights it would be very helpful!

謝謝,S

推薦答案

我不明白你用的是哪個庫.Python 標(biāo)準(zhǔn) urllib2 就足夠了:

I can't understand which library are you using. Python standard urllib2 is sufficient:

import urllib2, shutil

ftpfile = urllib2.urlopen("ftp://host.example.com/path/to/file")
localfile = open("/tmp/downloaded", "wb")
shutil.copyfileobj(ftpfile, localfile)

如果您需要登錄(匿名 登錄是不夠的),請在 url 中指定憑據(jù):

If you need to login (anonymous login isn't sufficient), then specify the credentials inside the url:

urllib2.urlopen("ftp://user:password@host.example.com/rest/of/the/url")

這篇關(guān)于用于連接 FTP 并下載文件的 Python 2.5 腳本的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Why I cannot make an insert to Python list?(為什么我不能插入 Python 列表?)
Insert a column at the beginning (leftmost end) of a DataFrame(在 DataFrame 的開頭(最左端)插入一列)
Python psycopg2 not inserting into postgresql table(Python psycopg2 沒有插入到 postgresql 表中)
list extend() to index, inserting list elements not only to the end(list extend() 索引,不僅將列表元素插入到末尾)
How to add element in Python to the end of list using list.insert?(如何使用 list.insert 將 Python 中的元素添加到列表末尾?)
TypeError: #39;float#39; object is not subscriptable(TypeError:“浮動對象不可下標(biāo))
主站蜘蛛池模板: 成人自拍av | 久久精品| 国产精品我不卡 | 中文字幕不卡在线88 | 欧美一级淫片免费视频黄 | 日本不卡视频 | 精品久久久久一区二区国产 | 日韩精品一区二区三区在线观看 | 亚洲网站在线观看 | 91视频一区二区三区 | 亚洲欧美激情精品一区二区 | 久久久男人的天堂 | www.国产一区| 久久久入口 | 九九热久久免费视频 | 一级二级三级在线观看 | 欧美日本一区二区 | 成人精品一区二区三区 | 久久狼人天堂 | 国产精品免费一区二区三区四区 | 欧美日韩国产在线观看 | 亚洲欧美久久 | 99久久精品免费视频 | 亚洲人成在线观看 | 看一级毛片| 久久久精彩视频 | 欧美日韩成人 | 国产精品久久久久久亚洲调教 | 精品伊人| 综合天天久久 | 玖玖玖在线 | 爱高潮www亚洲精品 中文字幕免费视频 | 91成人在线视频 | 久草视频在线播放 | 五月天天色 | 婷婷中文字幕 | 九色porny自拍视频 | 中文字幕乱码视频32 | 免费成人在线网站 | 欧美日韩在线一区二区 | 久久伊人一区 |