# Scrapy中文乱码解决 **一、得到html编码方式,一般有:utf-8,GBK,GB2312** 方法一:查看标签meta中属性charset的值 方法二:chardet查看 1.安装chardet:$ pip install chardet 2.代码:chardet.detect(string) **二、转换:GBK,GB2312转utf-8** ``` gbkContent = response.body.decode(chardet.detect(response.body)['encoding']) utf8Content = gbkContent.encode('utf-8') print utf8Content ``` Last modification:August 15th, 2020 at 04:33 pm © 允许规范转载 Support 众筹催更 ×Close Appreciate the author Sweeping payments Pay by AliPay Pay by WeChat