下载泰坦尼克号旅客数据集下载不下来?
```# 一、导入下载所需模块
# 导入urllib模块,将用于下载文件
import urllib.request
# 导入os模块,用于确认文件是否存在
import os
# 二、下载泰坦尼克号的旅客数据集
url="http://biostat.mc.vanderbilt.edu/wiki/pub/Main/DataSets/titanic3.xls"
filepath="Titanic/titanic3.xls"
if not os.path.isfile(filepath):
result=urllib.request.urlretrieve(url,filepath)
print('downloaded:',result)
gaierror Traceback (most recent call last)
~\anaconda3\envs\ten\lib\urllib\request.py in do_open(self, http_class, req, **http_conn_args)
1349 h.request(req.get_method(), req.selector, req.data, headers,
-> 1350 encode_chunked=req.has_header('Transfer-encoding'))
1351 except OSError as err: # timeout error
~\anaconda3\envs\ten\lib\http\client.py in request(self, method, url, body, headers, encode_chunked)
1276 """Send a complete request to the server."""
-> 1277 self._send_request(method, url, body, headers, encode_chunked)
1278
~\anaconda3\envs\ten\lib\http\client.py in _send_request(self, method, url, body, headers, encode_chunked)
1322 body = _encode(body, 'body')
-> 1323 self.endheaders(body, encode_chunked=encode_chunked)
1324
~\anaconda3\envs\ten\lib\http\client.py in endheaders(self, message_body, encode_chunked)
1271 raise CannotSendHeader()
-> 1272 self._send_output(message_body, encode_chunked=encode_chunked)
1273
~\anaconda3\envs\ten\lib\http\client.py in _send_output(self, message_body, encode_chunked)
1031 del self._buffer[:]
-> 1032 self.send(msg)
1033
~\anaconda3\envs\ten\lib\http\client.py in send(self, data)
971 if self.auto_open:
--> 972 self.connect()
973 else:
~\anaconda3\envs\ten\lib\http\client.py in connect(self)
943 self.sock = self._create_connection(
--> 944 (self.host,self.port), self.timeout, self.source_address)
945 self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
~\anaconda3\envs\ten\lib\socket.py in create_connection(address, timeout, source_address)
706 err = None
--> 707 for res in getaddrinfo(host, port, 0, SOCK_STREAM):
708 af, socktype, proto, canonname, sa = res
~\anaconda3\envs\ten\lib\socket.py in getaddrinfo(host, port, family, type, proto, flags)
751 addrlist = []
--> 752 for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
753 af, socktype, proto, canonname, sa = res
gaierror: [Errno 11001] getaddrinfo failed
During handling of the above exception, another exception occurred:
URLError Traceback (most recent call last)
<ipython-input-12-bde4817eb823> in <module>
3 filepath="Titanic/titanic3.xls"
4 if not os.path.isfile(filepath):
----> 5 result=urllib.request.urlretrieve(url,filepath)
6 print('downloaded:',result)
~\anaconda3\envs\ten\lib\urllib\request.py in urlretrieve(url, filename, reporthook, data)
245 url_type, path = splittype(url)
246
--> 247 with contextlib.closing(urlopen(url, data)) as fp:
248 headers = fp.info()
249
~\anaconda3\envs\ten\lib\urllib\request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context)
220 else:
221 opener = _opener
--> 222 return opener.open(url, data, timeout)
223
224 def install_opener(opener):
~\anaconda3\envs\ten\lib\urllib\request.py in open(self, fullurl, data, timeout)
523 req = meth(req)
524
--> 525 response = self._open(req, data)
526
527 # post-process response
~\anaconda3\envs\ten\lib\urllib\request.py in _open(self, req, data)
541 protocol = req.type
542 result = self._call_chain(self.handle_open, protocol, protocol +
--> 543 '_open', req)
544 if result:
545 return result
~\anaconda3\envs\ten\lib\urllib\request.py in _call_chain(self, chain, kind, meth_name, *args)
501 for handler in handlers:
502 func = getattr(handler, meth_name)
--> 503 result = func(*args)
504 if result is not None:
505 return result
~\anaconda3\envs\ten\lib\urllib\request.py in http_open(self, req)
1376
1377 def http_open(self, req):
-> 1378 return self.do_open(http.client.HTTPConnection, req)
1379
1380 http_request = AbstractHTTPHandler.do_request_
~\anaconda3\envs\ten\lib\urllib\request.py in do_open(self, http_class, req, **http_conn_args)
1350 encode_chunked=req.has_header('Transfer-encoding'))
1351 except OSError as err: # timeout error
-> 1352 raise URLError(err)
1353 r = h.getresponse()
1354 except:
URLError: <urlopen error [Errno 11001] getaddrinfo failed>
报错去百度查,有说是网络问题啥的,但是网络连接好的呀