问题描述
我遇到显示问题。我有一张要填写数据的图表。除了当我每行有多个数据而不是其他数据进入该行时,它们都留在同一行。例如,当我检索用户提及并且结果有3个screen_names时,我的输出是:a b c 除了b c从预期的列中突出并溢出到随后的列中。我希望a,b,c在同一列中: \ n b \ n c \ n 我的代码:
document
{%endfor%}
解决方法
您的HTML存在多个问题。您没有关闭标签,并且在循环的中间有一个随机的{%else%}。据我对您的问题的了解,您将希望采用以下格式:
{% for item in res %}
<tbody>
<tr>
<th scope="row">{{ item['_source']['lang'] }}</th>
<td>{{ item['_source']['id'] }}</td>
<td>{{ item['_source']['date'] }}</td>
<td>{{ item['_source']['full_text'] }}</td>
<td>{{ item['_source']['user']['name'] }}</td>
<td>{{ item['_source']['user']['screen_name'] }} </td>
<td>{{ item['_source']['user']['location'] }} </td>
<td>{{ item['_source']['user']['id'] }} </td>
<td>
{% for i in item['_source']['entities']['user_mentions'] if i["screen_name"] %}
{{ i["screen_name"] }}<br>
{% endfor %}
</td>
</tr>
</tbody>
{% endfor %}