吾のAPI盒纸

UTF-16 to GBK

import codecs

def ChangeUtf16ToGBK(u):
        u16c = codecs.lookup('utf-16')
        gbc = codecs.lookup('gbk')
        uc = u16c.decode(u)
        gc = gbc.encode(uc[0])
        return gc[0]

\uXXXX解析

u = '\u7535\u4fe1'
print u.decode("unicode-escape")

你可能感兴趣的:(吾のAPI盒纸)