【发布时间】:2018-08-22 08:34:23
【问题描述】:
我正在使用 Flask ,Jinja2 模板(html 文件)发布存储在 ABC.py 中的结果中的熊猫数据框表。 表格看起来像:Image
我正在使用字典来打印它,但它的格式不正确
<div class="col-sm-5 col-sm-offset-1">
{% if results is not none %}
<h2>Compare</h2>
<br>
<div id="results">
<table class="table table-striped" style="max-width: 300px;">
<thead>
<tr>
<th>Specifications</th>
<th>part1</th>
<th>part2</th>
</tr>
</thead>
{% for key,value in results.iterrows() %}
<tr> <option value = {{value[0]}} </option> </tr>
<tr>
<option value = "{{value[0]}}">{{value[1]}}</option>
</tr>
# <option value="{{ value['0']}}">{{value['1'] }}</option>
{% endfor %}
</table>
</div>
{% endif %}
</div>
必须使用 jinja2 模板做其他事情,但停留在非常底层。 请有任何建议。
谢谢
【问题讨论】:
标签: pandas flask jinja2 webapp2