从JSON到HTML表的迭代通过两个列表|瓶
输出,看人品如何开始在底部的另一个列表时结束:从JSON到HTML表的迭代通过两个列表|瓶
<table class="table">     <tr> 
    <th>Cast</th> 
    <th>Character</th> 
    </tr> 
    {% for cast in data[currentMovie]["cast"] %} 
    <tr> 
     <td>{{ cast }}</td> 
    {% endfor %} 
    {% for char in data[currentMovie]["character"] %} 
     <td>{{ char }}</td> 
</tr> 
    {% endfor %} 
</table> 
我想知道的是如何得到它,它并排,如现在角色从演员名单的最后开始。任何帮助表示赞赏!输出如上所示。
回答:
您正在循环首先“投射”,然后是“角色”。这是问题。 你应该循环两者同时进行类似
for cast, char in zip(data[currentMovie]["cast"], data[currentMovie]["character"]) 以上是 从JSON到HTML表的迭代通过两个列表|瓶 的全部内容, 来源链接: utcz.com/qa/264444.html








