unicode转义字符串转中文

  • 例如:"1u697cu897fu8fb9u5ba2u68afu697cu68afu53e3"

    unicode转义字符串转中文

    def decode_unicode(s): if pd.notna(s): # 提取开头的数字部分 start_number = "" for char in s: if char.isdigit(): start_number += char else: break # 一旦遇到非数字字符就停止 # 使用正则表达式提取 Unicode 编码部分 unicode_matches = re.findall(r'u([0-9a-fA-F]+)', s) # 将 Unicode 编码部分转换为中文字符 decoded_str = ''.join([chr(int(match, 16)) for match in unicode_matches]) return f'{start_number}{decoded_str}'

  • 转换后:"1楼西边客梯楼梯口"


发表评论

评论列表,共 0 条评论

    暂无评论