转换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

相关推荐
爱学习的小囧2 小时前
ESXi 8.0 原生支持 NVMe 固态硬盘吗?VMD 配置详解教程
linux·运维·服务器·esxi·esxi8.0
lUie INGA2 小时前
在2023idea中如何创建SpringBoot
java·spring boot·后端
坚持就完事了3 小时前
Linux中的变量
linux·运维·服务器
空中海3 小时前
第七章:vue工程化与构建工具
前端·javascript·vue.js
geBR OTTE3 小时前
SpringBoot中整合ONLYOFFICE在线编辑
java·spring boot·后端
Porunarufu3 小时前
博客系统UI自动化测试报告
java
Cat_Rocky3 小时前
利用Packet Tracer网络实验
linux·运维·服务器
zhensherlock3 小时前
Protocol Launcher 系列:Trello 看板管理的协议自动化
前端·javascript·typescript·node.js·自动化·github·js
zhuà!3 小时前
element的el-form提交校验没反应问题
前端·elementui
龙猫里的小梅啊3 小时前
CSS(一)CSS基础语法与样式引入
前端·css