如果我跑:
urllib2.urlopen('http://google.com')
Run Code Online (Sandbox Code Playgroud)
即使我使用其他网址,我也会遇到同样的错误.
我很确定我的计算机或路由器上没有运行防火墙,而且互联网(来自浏览器)运行正常.
我是 Python 新手,正在学习视频教程。
所以这是代码片段
from urllib.request import urlopen
with urlopen('http://sixty-north/c/t.txt') as story:
story_words = []
for line in story:
line_words = line.decode('utf-8').split()
for word in line_words:
story_words.append(word)
Run Code Online (Sandbox Code Playgroud)
我可以http://sixty-north.com/c/t.txt在我的浏览器中访问。
但是,当我在命令提示符中键入以下内容时:出现python words.py此错误:
C:\New folder>python words.py
Traceback (most recent call last):
File "C:\Python33\lib\urllib\request.py", line 1248, in do_open
h.request(req.get_method(), req.selector, req.data, headers)
File "C:\Python33\lib\http\client.py", line 1065, in request
self._send_request(method, url, body, headers)
File "C:\Python33\lib\http\client.py", line 1103, in _send_request
self.endheaders(body)
File "C:\Python33\lib\http\client.py", line 1061, in endheaders
self._send_output(message_body)
File "C:\Python33\lib\http\client.py", line 906, …Run Code Online (Sandbox Code Playgroud) urllib2似乎一般不支持使用代理身份验证的HTTPS,甚至更少使用NTLM身份验证.任何人都知道在代理上使用NTLM身份验证的HTTPS是否有补丁.
问候,
洛朗