发布时间:2019-09-16 07:35:53编辑:auto阅读(2265)
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
48925
48035
38800
35924
30344
27121
26125
20960
20784
19140
657°
737°
707°
706°
680°
641°
739°
825°
938°
1161°