簡體   English   中英

如何修復'urllib.error.HTTPError:HTTP錯誤404:找不到'

[英]How to fix 'urllib.error.HTTPError: HTTP Error 404: Not Found'

接下來是代碼:

import urllib
url=r'http://yann.lecun.com/exdb/mnist\train-images-idx3-ubyte.gz'
urllib.request.urlretrieve(url,'demo.zip')

接下來是錯誤:

HTTPError                                 Traceback (most recent call last)
<ipython-input-3-a702ad6c8455> in <module>()
      1 import urllib
      2 url=r'http://yann.lecun.com/exdb/mnist\train-images-idx3-ubyte.gz'
----> 3 urllib.request.urlretrieve(url,'demo.zip')

c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\urllib\request.py in urlretrieve(url, filename, reporthook, data)
    246     url_type, path = splittype(url)
    247 
--> 248     with contextlib.closing(urlopen(url, data)) as fp:
    249         headers = fp.info()
    250 

    221     else:
    222         opener = _opener
--> 223     return opener.open(url, data, timeout)
    224 
    225 def install_opener(opener):
    530         for processor in self.process_response.get(protocol, []):
    531             meth = getattr(processor, meth_name)
--> 532             response = meth(req, response)
    533 
    534         return response

    640         if not (200 <= code < 300):
    641             response = self.parent.error(
--> 642                 'http', request, response, code, msg, hdrs)
    643 
    644         return response

c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\urllib\request.py in error(self, proto, *args)
    562             http_err = 0
    563         args = (dict, proto, meth_name) + args
--> 564         result = self._call_chain(*args)
    565         if result:
    566             return result

c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\urllib\request.py in _call_chain(self, chain, kind, meth_name, *args)
    502         for handler in handlers:
    503             func = getattr(handler, meth_name)
--> 504             result = func(*args)
    505             if result is not None:
    506                 return result

HTTPError: HTTP Error 404: Not Found

如此糟糕的請求,您能幫我嗎..該錯誤不是針對代碼的。我想到了我的瀏覽器或urllib模塊錯誤。

該網址應顯示為:

http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz

mnist后出現反斜杠,導致將其解釋為制表符。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM