[英]Each time I go through a loop, how can I get the next item of a list to display
[英]In mako, how can I cycle through a list and display each value?
我有一个Python列表,我正在提供给模板:
{'error_name':'Please enter a name',
'error_email':'Please enter an email'}
并希望显示:
<ul>
<li>Please enter a name</li>
<li>Please enter an email</li>
</ul>
<ul>
% for prompt in whateveryoucalledit.values():
<li>${prompt}</li>
% endfor
</ul>
其中whateveryoucalledit
它是根据你选择了传球该容器(其中,作为评论注意到,是一个字典,而不是一个列表)的名称。 毕竟,关于mako的好处恰恰在于它非常接近Python本身(除了需要“稍微绕过”一些东西,并明确地关闭块而不仅仅是indend / deindent ;-)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.