Urllib 在 Python 3 中引发无效参数 URLError,urllib.request.urlopen

发布于 2024-09-26 02:19:40 字数 875 浏览 3 评论 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>     

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

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

醉酒的小男人 2024-10-03 02:19:40

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

Maybe try turning off the firewall? Since you are on Windows, that might be the problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文