0

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>     

我不知道是什么原因造成的。有人知道吗?

4

1 回答 1

2

也许尝试关闭防火墙?由于您使用的是 Windows,因此这可能是问题所在。

于 2010-10-03T19:37:40.340 回答