python中模板引擎Jinja2学习

1.Jinja2

Jinja2是基于python的模板引擎,功能比较类似于于PHP的smarty,J2ee的Freemarker和velocity。 它能完全支持unicode,并具有集成的沙箱执行环境,应用广泛。


2.简单的使用举例

from jinja2 import Template
template = Template('Hello {{ name }}!')
print template.render(name='World')
程序输出结果为:

[localhost ~]$ python test.py
Hello World!

你可能感兴趣的:(python中模板引擎Jinja2学习)