python2 编码 特殊字符无法解码问题

解决如下:


 é‡ç»„äººè¡¨çš®ç”Ÿé•¿å› å­å‡èƒ¶(易孚 如果存在这些特殊字符 有可能encode失败

  response = requests.get(url)

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

  html = etree.HTML(response.text)   # 正常    Unicode

 

猜你喜欢

转载自www.cnblogs.com/lzn-py/p/9272387.html
今日推荐