Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html Jinja2未加载模板_Html_Python 3.x_Jinja2 - Fatal编程技术网

Html Jinja2未加载模板

Html Jinja2未加载模板,html,python-3.x,jinja2,Html,Python 3.x,Jinja2,我遵循这一点,虽然我似乎做的每件事都正确,但它无法找到模板 jinja ├── main.py └── templates    └── hello_world 这是main.py中的代码 从jinja2导入文件系统加载器,环境 file\u loader=FileSystemLoader('模板') env=环境(加载器=文件加载器) template=env.get\u template('hello\u world.txt') output=template.render() 打印(输

我遵循这一点,虽然我似乎做的每件事都正确,但它无法找到模板

jinja
├── main.py
└── templates
    └── hello_world
这是main.py中的代码

从jinja2导入文件系统加载器,环境
file\u loader=FileSystemLoader('模板')
env=环境(加载器=文件加载器)
template=env.get\u template('hello\u world.txt')
output=template.render()
打印(输出)
错误-jinja2.exceptions.TemplateNotFound:hello\u world.txt

我想,错误在第4行,我已经试着从末尾删除该.txt,但仍然得到相同的错误


请帮助我,我一直在尝试解决这个问题,但似乎没有任何效果。

我确实在第5行的
hello\u world.txt
中遇到了相同的错误,但是如果我这样做
template=env.get\u template('hello\u world')
它就可以工作了。你确定你的
templates
文件夹名称中没有输入错误吗?我确实在第5行的
hello\u world.txt
中遇到了相同的错误,但是如果我这样做
template=env.get\u template('hello\u world')
它就正常工作了。您确定您的
模板
文件夹名称中没有输入错误吗?