TypeError: tuple indices must be integers, not str

后端 未结 5 600
孤街浪徒
孤街浪徒 2021-02-01 13:31

I am trying to pull data from a database and assign them to different lists. This specific error is giving me a lot of trouble \"TypeError: tuple indices must be integers, not s

5条回答
  •  Happy的楠姐
    2021-02-01 14:31

    The Problem is how you access row

    Specifically row["waocs"] and row["pool_number"] of ocs[row["pool_number"]]=int(row["waocs"])

    If you look up the official-documentation of fetchall() you find.

    The method fetches all (or all remaining) rows of a query result set and returns a list of tuples.

    Therefore you have to access the values of rows with row[__integer__] like row[0]

提交回复
热议问题