发布时间:2019-09-16 07:35:53编辑:auto阅读(2226)
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
48726
47760
38531
35730
30169
26904
25935
20779
20545
18937
325°
397°
434°
453°
439°
432°
483°
554°
666°
680°