转换html特殊符号

import html

import re

def replace_html(src_src):

replace_str=str.replace(src_src," "," ")

replace_str=str.replace(replace_str,"&lt;",'<')

replace_str=str.replace(replace_str,"&gt;",'>')

replace_str=str.replace(replace_str,"&amp;",'&')

replace_str=str.replace(replace_str,"&quot;",'"')

replace_str=str.replace(replace_str,"'","'")

replace_str=str.replace(replace_str,"&cent;",'¢')

replace_str=str.replace(replace_str,"&pound;",'£')

replace_str=str.replace(replace_str,"&yen;",'¥')

replace_str=str.replace(replace_str,"&euro;",'€')

replace_str=str.replace(replace_str,"&sect;",'§')

replace_str=str.replace(replace_str,"&copy;",'©')

replace_str=str.replace(replace_str,"&reg;",'®')

replace_str=str.replace(replace_str,"&trade;;",'™')

replace_str=str.replace(replace_str,"&times;",'×')

replace_str=str.replace(replace_str,"&divide;",'÷')

replace_str=str(html.unescape(src_src))

#replace_str=replace_str.replace(' ','{|}').replace(' ','{|}').replace('、','{|}')

replace_str=re.sub('[\s\u3002|\uff1f|\uff01|\uff0c|\u3001|\uff1b|\uff1a|\u201c|\u201d|\u2018|\u2019|\uff08|\uff09|\u300a|\u300b|\u3010|\u3011|\u007e]+','{|}',replace_str)

replace_str=re.sub('^\{\|\}','',replace_str)

replace_str=re.sub('\{\|\}$','',replace_str)

return replace_str

相关推荐
один but you13 分钟前
从可变参数到 emplace:现代 C++ 性能优化的核心组合
java·开发语言
IT_陈寒13 分钟前
Redis缓存击穿把我整不会了,原来还有这手操作
前端·人工智能·后端
YuanDaima204818 分钟前
Linux 进阶运维与 AI 环境实战:进程管理、网络排错与 GPU 监控
linux·运维·服务器·网络·人工智能
idcu35 分钟前
深入 Lyt.js 组件系统:L2 渲染引擎层的核心
前端·typescript
是码龙不是码农39 分钟前
ThreadPoolExecutor 7 个核心参数详解
java·线程池·threadpool
这是程序猿1 小时前
Spring Boot自动配置详解
java·大数据·前端
文心快码BaiduComate1 小时前
干货|Comate Harness Engineering工程实践指南
前端·后端·程序员
还有多久拿退休金1 小时前
一张栈的图,治好你面试答不出 script 阻塞的病
前端·javascript
光辉GuangHui1 小时前
Agent Skill 也需要测试:如何搭建 Skill 评估框架
前端·后端·llm
To_OC1 小时前
我终于搞懂 Claude Code 核心逻辑!90%的人都用错了模式
前端·ai编程