在python2的使用中,总会遇到各种各样的编码问题,这也是使用Python2最头疼的一件事情,幸好python3解决了编码的问题。
下面我在爬虫时遇到的类似é??????ooè?¨??????é???? ?-????è??(????-?格式的编码。
解决:
response = requests.get(url)
response.encoding = response.apparent_encoding # 将乱码进行编码
html = etree.HTML(response.text)
在python2的使用中,总会遇到各种各样的编码问题,这也是使用Python2最头疼的一件事情,幸好python3解决了编码的问题。
下面我在爬虫时遇到的类似é??????ooè?¨??????é???? ?-????è??(????-?格式的编码。
解决:
response = requests.get(url)
response.encoding = response.apparent_encoding # 将乱码进行编码
html = etree.HTML(response.text)
Python2中编码错误---é??ç»?人表ç?®ç??é?¿å? å?å??è?¶(æ??å?格式转化为UTF-8
原文:https://www.cnblogs.com/fanjp666888/p/8110572.html