发布时间:2019-09-16 07:35:53编辑:auto阅读(2395)
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
50473
49768
40359
37388
31810
28667
27602
22387
22384
20688
454°
1071°
870°
808°
1050°
925°
1539°
2877°
2579°
1977°