![](/img/trans.png)
[英]Python+Pyramid+Mako: What is the difference between the context in event, context in view and context in template?
[英]Does python mako template support connitue/break in loop context?
是否可以在%控制结构循环中使用continue / break。
例如:
% for x in range(1):
% continue
% endfor
谢谢,
是。 您使用<% continue %>
和<% break %>
。
例:
from mako.template import Template
t = Template(
"""
% for i in xrange(5):
% if i == 3:
<% break %>
% endif
${i}
% endfor
% for i in xrange(5):
% if i == 3:
<% continue %>
% endif
${i}
% endfor
""")
print t.render()
输出:
0
1
2
0
1
2
4
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.