Python2中编码错误---重组人表皮生长因子凝胶(易孚格式转化为UTF-8

在python2的使用中,总会遇到各种各样的编码问题,这也是使用Python2最头疼的一件事情,幸好python3解决了编码的问题。

下面我在爬虫时遇到的类似é‡ç»„äººè¡¨çš®ç”Ÿé•¿å› å­å‡èƒ¶(易孚格式的编码。

解决:

  response = requests.get(url)

  response.encoding = response.apparent_encoding  # 将乱码进行编码

  html = etree.HTML(response.text)

原文地址:https://www.cnblogs.com/fanjp666888/p/8110572.html