Python 当我从mysql数据库表中获取fetch数据时,它以{coloumn_name:data}的fomt形式给出输出

Python 当我从mysql数据库表中获取fetch数据时,它以{coloumn_name:data}的fomt形式给出输出,python,mysql,flask,Python,Mysql,Flask,这是我的Python代码 @app.route('/customer') def admin_customer(): cur=mysql.connection.cursor() res=cur.execute("SELECT NUM,USERNAME,USEREMAIL,MOBILE FROM customertable") cur.execute("SELECT * FROM customertabl

这是我的Python代码

    @app.route('/customer')
    def admin_customer():
        cur=mysql.connection.cursor()
        res=cur.execute("SELECT NUM,USERNAME,USEREMAIL,MOBILE FROM customertable")
        cur.execute("SELECT * FROM customertable")
        data = cur.fetchall()
        print(data)
        return render_template('users.html', data=data)
{% for row in data %}

    <tr>
        <td>{{row.0}}</td>
        <td>{{row.1}}</td>
        <td>{{row.2}}</td>
    </tr>

{%endfor%}
我的Html代码

    @app.route('/customer')
    def admin_customer():
        cur=mysql.connection.cursor()
        res=cur.execute("SELECT NUM,USERNAME,USEREMAIL,MOBILE FROM customertable")
        cur.execute("SELECT * FROM customertable")
        data = cur.fetchall()
        print(data)
        return render_template('users.html', data=data)
{% for row in data %}

    <tr>
        <td>{{row.0}}</td>
        <td>{{row.1}}</td>
        <td>{{row.2}}</td>
    </tr>

{%endfor%}
{%用于数据%中的行]
{{row.0}}
{{row.1}}
{{row.2}}
{%endfor%}
输出照片
我不确定您面临的问题是什么,因为您没有向我们显示任何错误。但是,就我而言,这是
mysql
库的预期行为。要正确呈现列表,请按名称访问字典键:

{% for row in data %}
    <tr>
        <td>{{row.USERID}}</td>
        <td>{{row.USERNAME}}</td>
        <td>{{row.USEREMAIL}}</td>
    </tr>
{%endfor%}
{%用于数据%中的行]
{{row.USERID}
{{row.USERNAME}
{{row.USEREMAIL}}
{%endfor%}

您的问题是什么?