python在gbk编码转换成utf-8时乱码问题

#项目爬虫,环境python-下载导入requests、lxml包
#url时是查ip位置的接口
url_1='http://www.ip138.com/ips138.asp?ip='+str(kh_ip)+'&action=2'
#导入requests库.获取整个页面文档
html_1=requests.get(url_1).text
#先encode('iso-8859-1')转换成'iso-8859-1编码,后转GBK就ok了
print(html_1.encode('iso-8859-1').decode('gbk'))

网友们遇事一定要冷静哦,要不然越搞越乱,转载请携带链接哦。

猜你喜欢

转载自blog.csdn.net/qq_43061705/article/details/83472196
今日推荐