我在这里定义一个函数并进行查询。
def fetch(temp_pass,temp_accno):
cur.execute('''SELECT id, name, acc_no, ph_no,address, email,balance
FROM accounts
WHERE id = %s and acc_no = %s''',
(str(temp_pass), str(temp_accno)));
row = cur.fetchall()
print(row[2])
在这一行中应该是一个长度为 7 的列表,但是当我运行print(row[2]) 时,它给我的错误是列表索引超出范围。
这是我得到的错误
File "Accounting.py", line 13, in fetch
print(row[2])
IndexError: list index out of range