ker*_*win 7 python templates loops mako
是否可以在%控制结构循环中使用continue/break.
例如:
% for x in range(1):
 % continue
% endfor
谢谢,
shi*_*zhi 15
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() 
| 归档时间: | 
 | 
| 查看次数: | 2875 次 | 
| 最近记录: |