python源码大全汉字GBK与Unicode

Python 代码库之unicode 编码与字符串之间相互转换

2019-08-11  本文已影响2人  iCloudEnd

Python 代码库之unicode 编码与字符串之间相互转换

chr(57344)
'\ue000'
 ord('\ue000')
57344

U+xxxx 转为字符 方法一

def u2w(mstr):
    t=mstr
    t=t.replace('U+','\\u') 
    return json.loads(f'"{t}"') 

U+xxxx 转为字符 方法二

def u2w(cstr):
    return chr(int('0x'+cstr,16))

更多精彩代码请关注我的专栏

上一篇 下一篇

猜你喜欢

热点阅读