Python 无法使索引函数在cs50 finance中工作

Python 无法使索引函数在cs50 finance中工作,python,html,database,jinja2,cs50,Python,Html,Database,Jinja2,Cs50,我完全被困在使索引功能在cs50财务工作!此函数应在html页面中返回一个表,其中包含在线交易的详细信息。详细信息保存在数据库中。但它不起作用:即使我的数据库中有一个事务,我的函数也找不到它,表是空的。 这是我的代码: def索引: 显示股票组合 rows=db.executeSELECT symbol,price,shares FROM transactions,其中id=:user\u id,user\u id=session[user\u id] 交易信息=[] 总价值=0 对于行中的事务

我完全被困在使索引功能在cs50财务工作!此函数应在html页面中返回一个表,其中包含在线交易的详细信息。详细信息保存在数据库中。但它不起作用:即使我的数据库中有一个事务,我的函数也找不到它,表是空的。 这是我的代码:

def索引: 显示股票组合 rows=db.executeSELECT symbol,price,shares FROM transactions,其中id=:user\u id,user\u id=session[user\u id] 交易信息=[] 总价值=0 对于行中的事务处理信息: symbol=行[0][symbol] 共享=行[0][共享] 价格=查找符号 价值=股票*价格[价格] 总价值+=总价值 交易信息。追加交易信息 返回render_templateindex.html,行=行,事务信息=事务信息 这是我的HTML页面:

{% extends "layout.html" %}

{% block title %}
    Index
{% endblock %}

{% block main %}

   <table class="table table-striped" style="width:100%">
    <tr>
     <th>Symbol</th>
     <th>Company</th>
     <th>Shares</th>
     <th>Price</th>
     <th>TOTAL</th>
   </tr>
 {% for transaction in transactions %}
   <tr>
     <td>{{ transaction_info.symbol }}</td>
     <td>{{ transaction_info.name }}</td>
     <td>{{ transaction_info.shares }}</td>
     <td>{{ transaction_info.price }}</td>
     <td>{{ transaction_info.worth }}</td>
   </tr>
   {% endfor %}
 </table>
  {% endblock %}
谢谢你的帮助

在索引中,您将在此处发送一个名为“事务信息”的列表 返回render_templateindex.html,行=行,事务信息=事务信息


在html中,您在名为transactions here{%for transaction In transactions%}的列表上循环。

这是一个代码吗?你做了什么来调试这个?谢谢!我不敢相信我错过了:-/