Python 3.2问题

发布于 2024-11-07 07:23:16 字数 177 浏览 4 评论 0原文

我正在使用Python 3.2。我可以像 2.x 版本一样导入“urllib”库。但我找不到 urlopen、urlretrieve 等方法。这是怎么回事?如何在 v3.2 上检索网页?

我尝试导入 urllib2 和 urllib3 库。但我的机器说它找不到这些模块,因此无法导入。为什么 v3.2 不支持这两个最新的库?

I am using Python 3.2. I can import "urllib" library just like with 2.x version. But I can't find methods such as urlopen, urlretrieve, etc. What gives? How do I retrieve a webpage on v3.2?

I have tried to import urllib2 and urllib3 libraries. But my machine says it can't find those modules so not importable. Why these two newest libraries aren't supported in v3.2?

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

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

发布评论

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

评论(4

送舟行 2024-11-14 07:23:16

您应该使用urllib.request。示例此处

You should use urllib.request. Example here.

旧城烟雨 2024-11-14 07:23:16

2.x 文档提到,在 Python 3.x 中,模块已分为urllib.requesturllib.error。如果您有一些 Python 2.x 代码并希望将模块转换为 3.x,您可以使用 2to3 工具。

The 2.x docs mention that in Python 3.x, the modules have been split into urllib.request and urllib.error. If you have some Python 2.x code and want to convert the modules to 3.x, you may be able to use the 2to3 tool.

粉红×色少女 2024-11-14 07:23:16

它在新版本中发生了变化,现在被拆分为 urllib.request。

from urllib.request import urlopen

您要查找的很多内容都在 urllib.request 的 python 库部分中 有人刚刚提到了一个实际的示例显示如何使用 urllib.request.urlopen 的文档。

It was changed in the newer versions and was split up to now be urllib.request.

from urllib.request import urlopen

A lot of what you're looking for is in the python library section on urllib.request and someone just mentioned an actual example from the documents that shows how the urllib.request.urlopen can be used.

我的痛♀有谁懂 2024-11-14 07:23:16

Python 3000 代表着与过去的决裂。函数已被清理,语法已被修改,并且标准库已被重新组织以提供更逻辑的任务和能力分组。

TL;DR:事情发生了变化

Python 3000 represents a break with the past. Functions have been cleaned up, syntax has been modified, and the stdlib has been reorganized to provide a more logical grouping of tasks and abilities.

TL;DR: Things change.

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