如何在烧瓶模板上输出列表的列表[]?
我有桌子[]
table = [[ str(i + 1) if (i + 1) % 2 == 0 else i + 1,
href[i] if (i + 1) % 2 == 0 else href[i],
href2[i] if (i + 1) % 2 == 0 else href2[i]] for i in range(len(href))]
return render_template('index.html',table=table)
我想要这样
<table>
<tr>
{% for table in table %}
<th>{{href[1]}} ,{{href2[1]}}</th>
{% endfor %}
</tr>
</table>
我想要这个输出
<table>
<tr>
<th>href[1] ,href2[1]</th>
<th>href[2] ,href2[2]</th>
<th>href[3] ,href2[3]</th>
...
</tr>
</table>
答案 0 :(得分:0)
所以看起来你的桌子是
[ [ "A", "B", "C" ],
[ "1", "2", "3" ] ]
等
所以你的循环应该是
{% for row in table %}
<th>{{row[0]}} ,{{row[1]}}</th>
{% endfor %}