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.
有一个whatever我想在 Jinja 中逐项列出的列表:
whatever
<ol> {% for item in whatever %} <tr> <td> <li> {{ item }}</li> </td> </tr> {% endfor %} </ol>
但是,当我以这种方式实现时,我得到无序列表输出而不是序列号,即
而不是
这实际上是您的 html(而不是 python / jinja)的问题。如果您删除tr/td标签就可以了。
tr
td
更新:如果您坚持使用 table 标签,请删除ol/li标签,并使用jinja循环loop中隐式定义的对象。for那是,
ol
li
loop
for
<td>{{loop.index}}. {{item}}</td>
会给你枚举项。