2 sinat 27634939 sinat_27634939 于 2017.01.16 19:40 提问

urlopen以一种访问权限不允许的方式做了一个访问套接字的尝试。 1C

import urllib.request
url="http://www.baidu.com"
req=urllib.request.urlopen(url)
然后报错
Traceback (most recent call last):
File "D:\python344\lib\urllib\request.py", line 1183, in do_open
h.request(req.get_method(), req.selector, req.data, headers)
File "D:\python344\lib\http\client.py", line 1137, in request
self._send_request(method, url, body, headers)
File "D:\python344\lib\http\client.py", line 1182, in _send_request
self.endheaders(body)
File "D:\python344\lib\http\client.py", line 1133, in endheaders
self._send_output(message_body)
File "D:\python344\lib\http\client.py", line 963, in _send_output
self.send(msg)
File "D:\python344\lib\http\client.py", line 898, in send
self.connect()
File "D:\python344\lib\http\client.py", line 871, in connect
self.timeout, self.source_address)
File "D:\python344\lib\socket.py", line 516, in create_connection
raise err
File "D:\python344\lib\socket.py", line 507, in create_connection
sock.connect(sa)
OSError: [WinError 10013] 以一种访问权限不允许的方式做了一个访问套接字的尝试。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in
req=urllib.request.urlopen(url)
File "D:\python344\lib\urllib\request.py", line 161, in urlopen
return opener.open(url, data, timeout)
File "D:\python344\lib\urllib\request.py", line 464, in open
response = self._open(req, data)
File "D:\python344\lib\urllib\request.py", line 482, in _open
'_open', req)
File "D:\python344\lib\urllib\request.py", line 442, in _call_chain
result = func(*args)
File "D:\python344\lib\urllib\request.py", line 1211, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "D:\python344\lib\urllib\request.py", line 1185, in do_open
raise URLError(err)
urllib.error.URLError:

1个回答

oyljerry
oyljerry   Ds   Rxr 2017.01.17 22:09

用管理员权限执行命令行,然后命令行中用python执行脚本试试

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!