我的HTML:https://pastebin.com/hyfv8ytw
`{% block main %}
<table class="table">
<thead class="thead-dark">
<tr>
<th scope="col">Food</th>
<th scope="col">Food Freshness</th>
<th scope="col">Feed this number of people</th>
<th scope="col">Pick up time</th>
<th scope="col">Address</th>
</tr>
</thead>
<tbody>
{% for r in req %}
<tr>
<th scope="row">{{ r[0] }}</th>
<td>{{ r[1] }}</td>
<td>{{ r[2] }}</td>
<td>{{ r[3] }}</td>
<td>{{ r[4] }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{%endblock%}`
这是我的python代码:https://pastebin.com/ehsaawi8
@app.route("/index1")
@login_required
def index1():
rows = db.execute("SELECT * FROM req WHERE user_id = :user",user=session["user_id"])
req = []
for row in rows:
req.append(list((row['food'], row['foodf'], row['nosofp'], row['timep'], row['address'])))
return render_template("index1.html", req=req)
问题是身体,头部很好。
DICT需要按html中的键(例如food
)来处理,而不是按索引来处理。