【python】 编码转换

#转码
def utf2gbk(string):
    #return string
    s=string.decode('utf-8','ignore').encode('gb18030','ignore')
    if s!=None:
        return s
    else:
        return string

  

原文地址:https://www.cnblogs.com/liyuxia713/p/3413105.html