先根据这个站点的编码,统一先该编码解码,解码得到unicode编码(python默认编码类型),再统一编码成utf-8。
SITE_CODE='gb2312'
#SITE_CODE='utf-8'
html_str.decode(SITE_CODE).encode('utf-8')
print html_str
先根据这个站点的编码,统一先该编码解码,解码得到unicode编码(python默认编码类型),再统一编码成utf-8。
SITE_CODE='gb2312'
#SITE_CODE='utf-8'
html_str.decode(SITE_CODE).encode('utf-8')
print html_str
转载于:https://my.oschina.net/airship/blog/634170