7676
7777 {% for index,element in enumerate(info) %}
7878 <p>info[{{index}}] is {{element}}
79- {\ % end %}
79+ {% end %}
8080
8181特别提醒注意的是,语句要用` {% end %} ` 来结尾。在循环体中,用` {{ element }} ` 方式使用序列的元素。
8282
@@ -96,18 +96,18 @@ index.py的代码不变,只修改模板index.html的代码,重点理解模
9696 <p>I will print the elements of this list in order.</p>
9797 {% for element in info %}
9898 <p>{{element}}</p>
99- {\ % end %}
99+ {% end %}
100100 <br>
101101 {% for index,element in enumerate(info) %}
102102 <p>info[{{index}}] is {{element}}
103103 {% if element == "python" %} <!-- 增加了一个判断语句 -->
104104 <p> <b>I love this language--{{element}}</b></p>
105- {\ % end %}
106- {\ % end %}
105+ {% end %}
106+ {% end %}
107107
108108 {% if "[email protected] " in info %} <!-- 还是判断一下 --> 109109 <p><b>A Ha, this the python lesson of LaoQi, It is good! His email is {{info[2]}}</b></p>
110- {\ % end %}
110+ {% end %}
111111 </body>
112112 </html>
113113
@@ -129,18 +129,18 @@ index.py的代码不变,只修改模板index.html的代码,重点理解模
129129 <p>I will print the elements of this list in order.</p>
130130 {% for element in info %}
131131 <p>{{element}}</p>
132- {\ % end %}
132+ {% end %}
133133 <br>
134134 {% for index,element in enumerate(info) %}
135135 <p>info[{{index}}] is {{element}}
136136 {% if element == "python" %}
137137 <p> <b>I love this language--{{element}}</b></p>
138138 {% end %}
139- {\ % end %}
139+ {% end %}
140140
141141 {% if "[email protected] " in info %} 142142 <p><b>A Ha, this the python lesson of LaoQi, It is good! His email is {{info[2]}}</b></p>
143- {\ % end %}
143+ {% end %}
144144 <h2>Next, I set "python-tornado"(a string) to a variable(var)</h2>
145145 {% set var="python-tornado" %}
146146 <p>Would you like {{var}}?</p>
@@ -154,3 +154,5 @@ index.py的代码不变,只修改模板index.html的代码,重点理解模
154154看官发现了吗?我用` {% set var="python-tornado" %} ` 的方式,将一个字符串赋给了变量` var ` ,在下面的代码中,就直接引用这个变量了。这样就是实现了模板中变量的使用。
155155
156156Tornado的模板真的功能不少呢。不过远非这些,后面还有。敬请等待。
157+
158+ [ 首页] ( ./index )   ;  ;  ; |  ;  ;  ; [ 上一讲:使用表单和模板] ( ./311.md )
0 commit comments