Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有以下格式的文本 & lt;div & gt;\n & lt;div & gt; & lt;span & gt;Customer .. 我怎样才能将此文本转换为 html 即
<div> <div> <span> Customer..
尝试:
import html html_string = "ampersand lt;div ampersand gt;\n ampersand lt;div ampersand gt; ampersand lt;span ampersand gt;Customer..".replace("ampersand ", "&") html.unescape(html_string)
如果您希望维护新线路:
html.unescape(html_string.replace("\n", "<br />"))