Django:显示列表列表中的值

the*_*eld 1 python django templates list matrix

我有一份清单清单

list = [[1,2,3],[4,5,6],[7,8,9]]

如何在模板中显示每个列表的第二个值:2,5,8?

<div>
    <ul class="list-group">
        {% for item in list %}
            {{ item[1] }},
        {% endfor %}
    </ul>
</div>
Run Code Online (Sandbox Code Playgroud)

ipe*_*kiy 5

您必须使用点表示法来访问列表项:

<div>
    <ul class="list-group">
        {% for item in list %}
            {{ item.1 }},
        {% endfor %}
    </ul>
</div>
Run Code Online (Sandbox Code Playgroud)