? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ✊
✊ ✊ ✊ ✊ ✊ ✊ ✊ ✊
过滤方法
Python怎么过滤 emoji表情符号呢? 下面是剔除表情字符串的代码片段 python3.6下测试
import redef re_emojis(text):emoji_pattern = pile("["u"\U0001F600-\U0001F64F"u"\U0001F300-\U0001F5FF"u"\U0001F680-\U0001F6FF"u"\U0001F1E0-\U0001F1FF""]+", flags=re.UNICODE)return emoji_pattern.sub(r' ', text)text = 'Lamo see this edit guys?Hi guyhttp://ssoo ://gere comes one more video? Enjoy ♥️'print('init:', text)result = re_emojis(text)print(result)
init: Lamo see this edit guys?Hi guyhttp://ssoo ://gere comes one more video? Enjoy ♥️Lamo see this edit guys Hi guyhttp://ssoo ://gere comes one more video? Enjoy ♥️
这里根据 unicode 范围来删除表情符号,通用的和IOS中的,不是很全,也没找到非常全的list。后面证实还是有写过滤不掉
使用emoji库过滤
终端安装emoji包
pip3 install emoji
借用emoji过滤特殊表情
import emojiimport retext = emoji.demojize('Lamo see this edit guys?Hi guyhttp://ssoo ://gere comes one more video? Enjoy the song Its just for fun guys dont take it far serious?Comment down your views and comment? down for my next video♥️')result = re.sub(':\S+?:', ' ', text)print(result)
Lamo see this edit guys Hi guyhttp://ssoo ://gere comes one more video Enjoy the song Its just for fun guys dont take it far serious Comment down your views and comment down for my next video ️
这样就过滤的超级干净了。