Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个要提供给模板的 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 本身非常接近(除了需要“绕开”一些东西,并明确地关闭块,而不仅仅是缩进/缩进;-)。
whateveryoucalledit