【发布时间】:2017-09-18 23:19:36
【问题描述】:
我有一些使用 LAMP 堆栈构建网站的基本经验。我也有一些使用 Python 进行数据处理的经验。我正试图掌握 mongodb-flask-python 的东西,所以我使用这个样板启动了所有内容:https://github.com/hansonkd/FlaskBootstrapSecurity
一切都好。
为了进行实验,我尝试声明一个变量并打印它...
我收到此错误消息:
TemplateSyntaxError: Encountered unknown tag 'x'. Jinja was looking for the following tags: 'endblock'. The innermost block that needs to be closed is 'block'.
这是我的主要 index.html 页面
{% extends "base.html" %}
{% block content %}
<div class="row">
<div class="col-xs-12">
Hello World, at {{ now }}, {{ now|time_ago }}
</div>
</div>
<div class="row-center">
<div class="col">
{% x = [0,1,2,3,4,5] %}
{% for number in x}
<li> {% print(number) %}
{% endfor %}
</div>
</div>
{% endblock %}
我喜欢学习新事物,但是伙计,我能不能花几个小时在最简单的事情上……任何帮助将不胜感激!!!
【问题讨论】:
-
你能展示你的python代码吗
-
{% 设置 x = [0,1,2,3,4,5] %}