如何从字符串列表中删除\uxxx?

2024-09-30 01:29:39 发布

您现在位置:Python中文网/ 问答频道 /正文

我想删除所有以\u开头的单词。我相信这些是unicode“\uxxx”

原始字符串:

"RT  \u2066als \u2066@WBHoekstra\u2069 zijn poot maar stijf houdt in de Italiaanse kwestie. Leest Mattheus 25, 2-13 '"

期望输出:

"RT @WBHoekstra zijn poot maar stijf houdt in de Italiaanse kwestie. Leest Mattheus 25, 2-13 '"

我试着像这样使用正则表达式:

re.sub('\u\w+','',item )

但我得到了以下错误:

"SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 0-1: truncated \uXXXX escape"

Tags: inunicodede单词rtkwestieleestmattheus

热门问题