我在我的计算机上测试来自http://docs.python.org/py3k/library/urllib.request.html的代码(Ubuntu 10.04和python 3.2)
>>> import urllib.request
>>> req = urllib.request.Request(url='https://localhost/cgi-bin/test.cgi',
... data=b'This data is passed to stdin of the CGI')
>>> f = urllib.request.urlopen(req)
>>> print(f.read().decode('utf-8'))
Got Data: "This data is passed to stdin of the CGI"
使用服务器
python3 -m http.server
在urlopen(req)时收到以下消息:
......
ssl.SSLError: [Errno 1] _ssl.c:390: error:140770FC:SSLroutines:SSL23_GET_SERVER_HELLO:unknown protocol
During handling of the above exception, another exception occurred:
......
urllib.error.URLError: <urlopen error [Errno 1] _ssl.c:390: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol>
有什么建议吗?非常感谢。