我想删除所有以\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"
您可以使用
.encode('ascii', 'ignore')
来实现这一点输出
相关问题 更多 >
编程相关推荐