python - 属性错误 : module 'request' has no attribute 'urlopen'

标签 python html url compiler-errors urllib

我一直收到这个错误,我很困惑

最佳答案

您可能想要做的是导入 request来自 urllib 的模块包,所以你可以使用 urlopen request 中定义的函数模块。

import urllib.request

urllib.request.urlopen('https://stackoverflow.com/')

附加信息:

The legacy urllib.urlopen function from Python 2.6 and earlier has been discontinued; urllib.request.urlopen() corresponds to the old urllib2.urlopen. Proxy handling, which was done by passing a dictionary parameter to urllib.urlopen, can be obtained by using ProxyHandler objects. (https://docs.python.org/3/library/urllib.request.html)

关于python - 属性错误 : module 'request' has no attribute 'urlopen' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59093489/

相关文章:

python - 一组独特的列表

javascript - 如何更改鼠标悬停时下拉选项的背景颜色?

http - URL "scheme plus authority"的正式名称

Apache 重写规则在一台服务器上工作,但在另一台主机上出现 500 错误

php - 重写 URL 中的单词 - wordpress

python - 如何停止networkx来更改源节点和目标节点?

python - 从 numpy 矩阵中提取子矩阵的快速方法

python - 比较两个列表的元素

html - 如何将我所有的 li 对齐在一列上?

iphone - 网页可以向左拖动并在移动 View 中放大/缩小