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

相关推荐
子兮曰5 小时前
async/await高级模式:async迭代器、错误边界与并发控制
前端·javascript·github
oak隔壁找我5 小时前
JVM常用调优参数
java·后端
恋猫de小郭5 小时前
2026 Flutter VS React Native ,同时在 AI 时代 VS Native 开发,你没见过的版本
android·前端·flutter
GIS之路7 小时前
ArcGIS Pro 中的 Notebooks 入门
前端
IT_陈寒8 小时前
React状态管理终极对决:Redux vs Context API谁更胜一筹?
前端·人工智能·后端
蝎子莱莱爱打怪9 小时前
OpenClaw 从零配置指南:接入飞书 + 常用命令 + 原理图解
java·后端·ai编程
Kagol9 小时前
TinyVue 支持 Skills 啦!现在你可以让 AI 使用 TinyVue 组件搭建项目
前端·agent·ai编程
柳杉9 小时前
从零打造 AI 全球趋势监测大屏
前端·javascript·aigc
simple_lau9 小时前
Cursor配置MasterGo MCP:一键读取设计稿生成高还原度前端代码
前端·javascript·vue.js
睡不着先生9 小时前
如何设计一个真正可扩展的表单生成器?
前端·javascript·vue.js