【发布时间】:2010-09-21 11:16:35
【问题描述】:
我有一个 HTML 编码的字符串:
'''<img class="size-medium wp-image-113"\
style="margin-left: 15px;" title="su1"\
src="http://blah.org/wp-content/uploads/2008/10/su1-300x194.jpg"\
alt="" width="300" height="194" />'''
我想把它改成:
<img class="size-medium wp-image-113" style="margin-left: 15px;"
title="su1" src="http://blah.org/wp-content/uploads/2008/10/su1-300x194.jpg"
alt="" width="300" height="194" />
我希望将其注册为 HTML,以便浏览器将其呈现为图像,而不是显示为文本。
字符串是这样存储的,因为我使用了一个名为 BeautifulSoup 的网络抓取工具,它“扫描”网页并从中获取某些内容,然后以该格式返回字符串。
我在 C# 中找到了如何做到这一点,但在 Python 中却没有。有人可以帮帮我吗?
相关
【问题讨论】:
标签: python django html-encode