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

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

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

問題描述

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

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 標準 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 中指定憑據:

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")

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

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

相關文檔推薦

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:“浮動對象不可下標)
主站蜘蛛池模板: 尤物在线精品视频 | 国产小视频在线看 | 99在线免费观看视频 | 一区二区免费在线观看 | 亚洲男女激情 | 毛片视频免费 | 亚洲第一黄色网 | 国产日韩91| 欧美中文字幕一区二区三区亚洲 | 成人妇女免费播放久久久 | 91视频国产区 | 国产成人在线播放 | 黄色精品 | 国产欧美精品区一区二区三区 | 罗宾被扒开腿做同人网站 | 午夜精品三区 | 91久久精品国产91久久 | 99成人| 亚洲精品不卡 | xx视频在线观看 | 欧美日韩国产一区二区三区 | 国产精品小视频在线观看 | 国产午夜一级 | 国产中文视频 | 成人久久18免费网站麻豆 | 日韩欧美不卡 | 中文字幕第九页 | 久久aⅴ乱码一区二区三区 91综合网 | 免费的色网站 | 羞羞视频在线观免费观看 | 亚洲va国产日韩欧美精品色婷婷 | 亚洲成网| 午夜视频在线观看网站 | 免费观看成人鲁鲁鲁鲁鲁视频 | 久久久久久免费毛片精品 | 欧美乱操 | 国产精品一区二区无线 | 久久久国产精品一区 | 毛片a级 | 91视频在线看 | 亚洲欧美日韩精品久久亚洲区 |