开发者社区> 问答> 正文

如何修复'urllib.error.HTTPError:HTTP错误404:未找到'

一码平川MACHEL 2019-01-17 16:21:05 2690

import urllib
url=r'http://yann.lecun.com/exdb/mnisttrain-images-idx3-ubyte.gz'
urllib.request.urlretrieve(url,'demo.zip')
接下来是错误:

HTTPError Traceback (most recent call last)
in ()

  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 studiosharedpython36_64liburllibrequest.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 studiosharedpython36_64liburllibrequest.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 studiosharedpython36_64liburllibrequest.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

Python
分享到
取消 提交回答
全部回答(1)

集结各类场景实战经验,助你开发运维畅行无忧

推荐文章
相似问题