发布时间:2019-09-16 07:35:53编辑:auto阅读(2749)
flask 有3种方法可以关闭自动转义:
1、在Python文件中进行转义。先在 Markup 对象中进行转义,然后将它传送给模版。一般推荐使用这个方式。
from flask import Markup
result=Markup(result(params));
return render_template('xxx.html', result=result)
2、在模版文件中进行转义。通过 |safe 过滤器来表示字符串是安全的({{result|safe}})
渲染的时候 {{ result|safe }}
3、暂时禁用全局的自动转义功能。
{% autoescaping false %}
<p>autoescaping is disableed here
<p>` will_not_be_escaped `
{% endautoescape %}
可参考官方资料
http://flask-cn.readthedocs.org/en/latest/templating/
上一篇: Python json.dumps 中文
下一篇: 关于python中 __init__.p
52676
52588
42728
39601
33992
30956
29750
24638
24477
22861
209°
218°
285°
270°
305°
463°
439°
453°
526°
449°