开发者社区> 问答> 正文

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

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

展开
收起
一码平川MACHEL 2019-01-17 16:21:05 15602 0
1 条回答
写回答
取消 提交回答
问答排行榜
最热
最新

相关电子书

更多
阿里巴巴HTTP 2.0实践及无线通信协议的演进之路 立即下载
CDN助力企业网站进入HTTPS时代 立即下载
低代码开发师(初级)实战教程 立即下载