从Python字符串中删除表情符号
? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ✊
✊ ✊ ✊ ✊ ✊ ✊ ✊ ✊
过滤方法
Python怎么过滤 emoji表情符号呢? 下面是剔除表情字符串的代码片段 python3.6下测试
import re
def re_emojis(text):emoji_pattern = re.compile("["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 emoji
import re
text = 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 ️
这样就过滤的超级干净了。
从Python字符串中删除表情符号相关推荐
- python中指定最后一个字符_如何从Python字符串中删除最后一个字符?
如何从Python字符串中删除最后一个字符? Python支持负索引切片和正切片.负索引从 -1 到-(iterable_length)开始.我们将使用负切片从可迭代对象的末尾获取元素. 索引 - ...
- html5列表去掉符号,从Python字符串中删除不在允许列表中的HTML标记
尚方宝剑之说 我使用FilterHTML.它很简单,允许您定义一个控制良好的白名单,擦除URL,甚至匹配正则表达式的属性值或每个属性具有自定义过滤功能.如果小心使用它可能是一个安全的解决方案.以下是自 ...
- python删除空白没有显示_删除Python字符串中的空白
一般的问题是从python字符串中删除所有多余的空格,这样每个单词之间只有一个空格,而字符串的开头或结尾没有空格.在 例如, "Hello to the world"将返回为&qu ...
- java将表情字符串转表情符号_使用java将字符串中的表情符号替换为字符串
如何从字符串中删除表情符号我的简单代码是.. public static void main(String[] args) throws SQLException { String str=" ...
- [转载] Python从字符串中删除字符
参考链接: Python | 字符串translate Sometimes we want to remove all occurrences of a character from a string ...
- python字符串去掉空行_Python从字符串中删除空格
python字符串去掉空行 There are various ways to remove spaces from a string in Python. This tutorial is aime ...
- Python从字符串中删除字符
Sometimes we want to remove all occurrences of a character from a string. There are two common ways ...
- 从 Python 中的字符串中删除最后一个分号或者逗号
第一种方法 使用 str.rstrip() 方法从字符串中删除最后一个逗号,例如 new_str = my_str.rstrip(';'). str.rstrip() 方法将返回删除尾随逗号的字符串副 ...
- python编程—输入两个字符串,从第一字符串中删除第二个字符串中所有的字符
题目描述: 输入两个字符串,从第一字符串中删除第二个字符串中所有的字符.例 如,输入"They are students."和"aeiou", 则删除之后的第一 ...
最新文章
- HoloLens开发入门
- 体验Windows Azure的Access Control Service
- CF508D Tanya and Password(欧拉回路)
- sql子查询示例_学习SQL:SQL查询示例
- hbase shell远程连接_HBase安装详解
- 【iOS】Unlock iPhone to Continue Xcode cannot launch demo1_greating on iPhone because the device is lo
- Vue源码:mustache模板引擎学习
- 刽子手c语言,竞赛题目选讲——刽子手的游戏(C语言)
- FPGA智能网卡功能剖析
- 【问】历史库存查询的结存数量和商品进销存报表的结存数量对不上
- 【122天】尚学堂高琪Java300集视频精华笔记(43-46)
- 365天历史时间顺序读经计划表
- 使用函数节流思想避免 SAP UI5 应用里按钮短时间内被高频重复点击试读版
- xgb.cv进行交叉验证
- Linux性能优化:性能优化工具
- linux系统修改时区
- Golang实习生字节一面
- 总结之CSIG-MIIP 2017
- JAVA优秀书籍推荐
- 【EXCEL】批量处理科学技术法的列为文本的函数
热门文章
- 分布式多副本一致性协议paxos
- 【Unity 实用工具】 Unity 十款 浏览器相关插件 整理(web view browser)
- 关于min-height等样式的使用
- 智能聊天机器人如何帮助跨境电商卖家提高成交转化率?
- Following verilog source has syntax error :
- 2011NBA季后赛playbyplay数据库
- 插入excel背景后,背景图片尺寸
- cogs 1114. [郑州培训2012] 暴力摩托
- 网络监控cacti1.2.12安装部署(一)
- python 如何利用字典中的一个键(key)存储多个值(列表)