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
网址应为:
http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz
你在mnist之后有一个反斜杠,导致它被解释为一个标签。
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。