1、重点理解

response.text返回的类型是str

response.content返回的类型是bytes,可以通过decode()方法将bytes类型转为str类型

推荐使用:response.content.decode()的方式获取相应的html页面

2、扩展理解

  • response.text 
    解码类型:根据HTTP头部对响应的编码做出有根据的推测,推测的文本编码 
    如何修改编码方式:response.encoding = 'gbk'
  • response.content 
    解码类型:没有指定 
    如何修改编码方式:response.content.decode('utf8')

相关文章:

  • 2022-01-22
  • 2021-12-02
  • 2022-01-14
  • 2021-10-14
  • 2021-11-26
  • 2022-02-04
  • 2021-12-12
猜你喜欢
  • 2021-05-12
  • 2021-12-23
  • 2021-08-22
  • 2021-05-23
  • 2021-12-25
相关资源
相似解决方案