我有两个版本的Index.html。一个与我的主Python文件位于同一文件夹中,另一个位于模板文件夹中。
from jinja2 import Environment, FileSystemLoader
WORKS:
template = env.get_template('{}'.format(sql_list[7]))
print('{}'.format(sql_list[7]))
输出:
index.html
DOESN'工作:
template = env.get_template('../templates/{}'.format(sql_list[7]))
print('../templates/{}'.format(sql_list[7]))
输出:
../templates/index.html
我真的不明白为什么它不起作用,因为它们在打印时具有完全相同的输出。但我需要在最后的模板文件夹中包含该文件:/。我不相信它会与同一个文件夹中的那个混淆,因为我尝试删除该文件并再次运行它。