最近在折腾python web的flask,碰到如下问题: 我有一个template叫index.html, 在body中包含如下内容
{% for item in news %}{{ item['description'] }}{% endfor %}
现在变量{{ item['description'] }}的内容如下
现任澳洲总理吉拉德在澳大利亚工党领袖选举中输给陆克文。
如何插入该变量的内容后,html正常解析这些标签??向大家求教 目前,{{ item['description'] }}的内容直接显示在页面上,也就是说
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
jinja 为了安全起见默认会对 html 进行转义,添加 safe 参数即可
{{ item['description']|safe }}