小编You*_*ung的帖子

在python中使用re删除unicode表情符号

我试图从unicode tweet文本中删除表情符号,并使用python 2.7打印出结果

myre = re.compile(u'[\u1F300-\u1F5FF\u1F600-\u1F64F\u1F680-\u1F6FF\u2600-\u26FF\u2700-\u27BF]+',re.UNICODE)
print myre.sub('', text)
Run Code Online (Sandbox Code Playgroud)

但似乎几乎所有的字符都从文本中删除.我从其他帖子中查了几个答案,不幸的是,这些都没有在这里工作.我在re.compile()中做错了吗?

这是一个删除所有字符的示例输出:

“   '   //./” ! # # # …
Run Code Online (Sandbox Code Playgroud)

python regex unicode tweets emoji

7
推荐指数
1
解决办法
1万
查看次数

标签 统计

emoji ×1

python ×1

regex ×1

tweets ×1

unicode ×1