【发布时间】:2021-10-10 20:02:26
【问题描述】:
我正在尝试使用 Flask 在我的 Web 应用程序上显示来自 CSV 文件的数据。在下面的代码中,我试图从我的 CSV 文件中选择 5 列,并在 HTML 表中显示这些列的值。不幸的是,出现在 HTML 表中的值是 {{ value [0] }}, {, {{ value [1] }}, { value [2] }}, {{ value [3] }}, {{值 [4] }},{{ 值 [5] }}。
我的python函数:
@app.route("/homepage")
def table_issues():
columns=["Regulatory_Domain","Detection_Date","ID_Client","Issue_ID_Name","Status_Issue","Comments"]
df = pd.read_csv("data.csv", names=columns, header= 0)
df = df.sort_values(by=['Detection_Date'], ascending = True)
issueslist = list (df.values)
return render_template("homepage.html", issueslist=issueslist)
我的 HTML 代码:
<table>
<thead class=theadissues>
<tr>
<th>Regulatory Domain</th>
<th>Detection Date</th>
<th>Client-ID</th>
<th>Issue ID / Name</th>
<th>Review Status</th>
<th>Comments</th>
<th>Edit</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ value[0] }}</td>
<td>{{ value[1] }}</td>
<td>{{ value[2] }}</td>
<td>{{ value[3] }}</td>
<td>{{ value[4] }}</td>
<td>{{ value[5] }}</td>
<td>
<p class="EditAction"><a href="/updateform">EDIT ISSUE</a></p>
</tr>
</tbody>
</table>
您能帮我更正我上面的代码吗?
非常感谢您的帮助。
【问题讨论】: