gpt4 book ai didi

python - 属性错误 : 'Response' object has no attribute 'text'

转载 作者:太空宇宙 更新时间:2023-11-03 12:39:48 26 4
gpt4 key购买 nike

page = requests.get(url)
tree = html.fromstring(page.text)

在第 2 行我得到:

AttributeError: 'Response' object has no attribute 'text'

我有导入的请求和安装的请求。我该如何调试这个错误?谁能告诉命令安装最新的请求模块?

最佳答案

您使用的是旧版本的requests,很可能是因为它是随Ubuntu Precise Pengolin (12.04LTS) 一起安装的.

您要么必须引用 version specific documentation或使用更新的版本。自 0.x 版本以来,requests 发生了翻天覆地的变化。

对于您的旧版本,如果您设置了 response.encodingresponse.content 将包含一个解码的 Unicode 值。

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

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com