在第2行,我得到:
AttributeError: 'Response' object has no attribute 'text'我已导入请求和已安装的请求。 我如何调试这个错误? 任何人都可以告诉命令安装最新的请求模块?
page = requests.get(url) tree = html.fromstring(page.text)At line 2 I get:
AttributeError: 'Response' object has no attribute 'text'I have imported requests and installed requests. How do I debug this error? can anyone tell command to install lastest requests module?
最满意答案
您使用的是古老版本的requests ,很可能是因为它安装了Ubuntu Precise Pengolin(12.04LTS) 。
您必须参考特定于版本的文档或使用更新的版本。 自0.x版本日以来, requests发生了巨大变化。
对于旧版本,如果您设置了response.encoding ,则response.content将包含解码的Unicode值。
You are using an ancient version of requests, most likely because it came installed with Ubuntu Precise Pengolin (12.04LTS).
You'll either have to refer to the version specific documentation or use a more recent version. requests has changed drastically since the 0.x version days.
For your old version, if you set response.encoding, response.content will contain a decoded Unicode value.
AttributeError:'Response'对象没有属性'text'(AttributeError: 'Response' object has no attribute 'text') page = requests.get(url) tree = html.fromstring(page.text)在第2行,我得到:
AttributeError: 'Response' object has no attribute 'text'我已导入请求和已安装的请求。 我如何调试这个错误? 任何人都可以告诉命令安装最新的请求模块?
page = requests.get(url) tree = html.fromstring(page.text)At line 2 I get:
AttributeError: 'Response' object has no attribute 'text'I have imported requests and installed requests. How do I debug this error? can anyone tell command to install lastest requests module?
最满意答案
您使用的是古老版本的requests ,很可能是因为它安装了Ubuntu Precise Pengolin(12.04LTS) 。
您必须参考特定于版本的文档或使用更新的版本。 自0.x版本日以来, requests发生了巨大变化。
对于旧版本,如果您设置了response.encoding ,则response.content将包含解码的Unicode值。
You are using an ancient version of requests, most likely because it came installed with Ubuntu Precise Pengolin (12.04LTS).
You'll either have to refer to the version specific documentation or use a more recent version. requests has changed drastically since the 0.x version days.
For your old version, if you set response.encoding, response.content will contain a decoded Unicode value.
发布评论