resp = requests.get(url) 

resp.content 是str类型

resp.text是unicode类型

 

如果返回的中文使用gbk编码,需要转换成utf-8的时候:

resp.content.decode('gb2312').encode('utf-8')

resp.content.decode('gb2312')   #从gbk转unicode

resp.content.decode('gb2312').encode('utf-8')  #将unicode编码编译成utf-8

相关文章:

  • 2021-12-25
  • 2021-11-30
  • 2022-12-23
  • 2021-11-30
  • 2021-07-06
  • 2021-10-10
  • 2022-12-23
  • 2021-11-14
猜你喜欢
  • 2021-07-26
  • 2021-09-14
  • 2022-12-23
  • 2022-12-23
  • 2021-07-24
  • 2022-12-23
相关资源
相似解决方案