Urllib raising invalid argument URLError in Python 3, urllib.request.urlopen
New to Python, but I'm trying to...retrieve data from a site:
import urllib.request
response = urllib.request.urlopen("http://www.python.org")
This is the same code I've seen from the Python 3.1 docs. And a lot of sites.
However, I get:
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>
I have no idea what's causing this. Anyone know?
Maybe try turning off the firewall? Since you are on Windows, that might be the problem.
精彩评论