2022年 11月 3日

Python去掉Unicode编码中的‘u‘开头

Unicode编码的字符串,print()显示为’\u….’开头,在Python中无法通过直接删除’\u’来获取后边的字符串,通过如下方法可以

'\uec88'.encode('raw_unicode_escape').decode('utf-8').replace('\\u', '')

得到’ec88’字符串。

参考资料:

https://www.ddpool.cn/article/65609.html