【发布时间】:2021-01-18 09:39:53
【问题描述】:
我是第一次运行 Python Jinja 模板文件,但是通过在线查找我没有找到明确的示例。
下面是我的代码,first.py 是我的 Python 应用程序,模板输出是 home.html
from jinja2 import Environment, PackageLoader, select_autoescape
env = Environment(loader=PackageLoader('first.py', 'templates'),
autoescape=select_autoescape(['html', 'xml'])
template = env.get_template('home.html')
print template.render(the='variables', go='here')
我缺少什么让它运行?渲染中应该包含什么变量?
【问题讨论】:
-
错误日志是什么?
-
我在图片上方添加了错误日志