久久久久久久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:“浮動對象不可下標)
主站蜘蛛池模板: 亚洲中午字幕 | 在线中文字幕日韩 | 91精品国产91久久久久久最新 | 日本三级线观看 视频 | 91aiai| 98成人网| 国产偷自视频区视频 | 国产精品视频不卡 | 一道本视频 | 色先锋影音 | 久草福利| 精品久久久久久亚洲精品 | 国产日韩欧美在线 | 91一区二区 | 欧美成人综合 | 欧洲高清转码区一二区 | 午夜精品一区二区三区在线 | 久久男人天堂 | 日韩一二区 | 淫片专区 | 欧美黄色网| 男人天堂色 | 欧美一级在线免费观看 | 中文字幕乱码一区二区三区 | 2020天天操 | 久久国| 毛色毛片免费看 | 美女视频h | 欧美日韩三区 | 国产精品久久久久久婷婷天堂 | 最新中文字幕在线 | 中文字幕av一区 | 99在线资源| 免费一区| 亚洲精品久久久一区二区三区 | 全免费a级毛片免费看视频免 | 西西裸体做爰视频 | 亚洲成人av | 中文字幕一区二区三区四区 | 欧美日韩亚洲一区 | 国产精品九九 |