#中文字符gbk转utf-8 def gbk2utf8(self,raw): rs=raw.encode('raw_unicode_escape') #转为机器识别字符串 s=repr(rs) ss=unicode(eval(s),"gbk") #gbk解码为unicode utf8_str=ss.encode('utf-8') #unicode编码为utf-8 return utf8_str