Python 3中urllib.request.urlopen引发无效参数URLError
我刚接触Python,但我想从一个网站上获取数据:
import urllib.request
response = urllib.request.urlopen("http://www.python.org")
这是我在Python 3.1的文档和很多网站上看到的相同代码。
但是,我得到了:
Message File Name Line Position
Traceback
<module> G:\My Documents\Python\HTTP.py 14
urlopen E:\Python 3.1\Lib\urllib\request.py 119
open E:\Python 3.1\Lib\urllib\request.py 342
_open E:\Python 3.1\Lib\urllib\request.py 360
_call_chain E:\Python 3.1\Lib\urllib\request.py 320
http_open E:\Python 3.1\Lib\urllib\request.py 1063
do_open E:\Python 3.1\Lib\urllib\request.py 1048
URLError: <urlopen error [Errno 10022] An invalid argument was supplied>
我不知道是什么原因导致的。有人知道吗?
1 个回答
2
你可以试着关掉防火墙吗?因为你用的是Windows系统,这可能就是问题所在。