<thead> <th> username </th> <th>place</th> </thead> {% for i, j in user_group1, user_group2 %} <tbody> {% if i %} <td>{{ i.username }}</td> <td>{{ i.place }}</td> {% else %} <td>{{ j.username }}</td> <td>{{ j.place }}</td> {% endif %} </tbody> {% endfor %}
我想在sinle表体中使用两个for循环。首先我需要开始第一个,然后我需要开始下一个。我该怎么做
如果您使用的是Jinja2,您可以使用 + 操作员:
+
{% for i in user_group1|list + user_group2|list %} <tbody> <td>{{ i.username }}</td> <td>{{ i.place }}</td> </tbody> {% endfor %}