代码:
# -*- coding: utf-8 -*-
from jinja2 import Environment, PackageLoader
env = Environment(loader = PackageLoader('app', 'templates'))
template = env.get_template('index.html')
print(template.render(message = "Bienvenue sur mon site !"))
运行后报错
NotImplementedError: Can't perform this operation for unregistered loader type
解决
添加文件 __init__.py
到app
文件夹下
参考
NotImplementedError: Can’t perform this operation for unregistered loader type