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

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

'\ue567'.encode('raw_unicode_escape').decode('utf-8').replace('\\u', '')
得到'e567'字符串。

posted @ 2022-05-26 20:11  myrj  阅读(0)  评论(0编辑  收藏  举报