![](/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.