去掉字符串中emoji字符
https://blog.csdn.net/weixin_45459224/article/details/105855545?utm_medium=distribute.pc_relevant.none-task-blog-title-6&spm=1001.2101.3001.4242
def filter_emoji(desstr, restr=''):
# 过滤表情
try:
co = re.compile(u'[\U00010000-\U0010ffff]')
except re.error:
co = re.compile(u'[\uD800-\uDBFF][\uDC00-\uDFFF]')
return co.sub(restr, desstr)
if __name__ == '__main__':
test_str = """服务周到,性价比高,量还多,强烈推荐😍😍😍"""
print(filter_emoji(test_str))
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
编辑 (opens new window)
上次更新: 2021/10/11, 12:43:58