我正在尝试将MySQLdb表中的数据插入到Treeview中,并且在运行程序时我收到语法错误:关键字arg.i之后的非关键字arg不知道这意味着我要求解释以及我如何能够解决这个问题。 `
from Tkinter import *
import ttk
import MySQLdb
root = Tk()
root.geometry("320x240")
tree = ttk.Treeview(root)
conn = MySQLdb.connect("localhost", "root", "drake", "OSCAR")
cursor = conn.cursor()
tree["columns"] = ("one", "two", "three")
tree.column("one", width=100)
tree.column("two", width=100)
tree.column("three", width=100)
tree.heading("#0", text='ID', anchor='w')
tree.column("#0", anchor="w")
tree.heading("one", text="NAME")
tree.heading("two", text="VOTES")
tree.heading("three", text="PERSENTAGE")
for i in range(1, 6):
cursor.execute("""select name from president where ID =%s""", (i,))
nm = cursor.fetchone()[0]
cursor.execute("""select votes from president where ID =%s""", (i,))
vot = cursor.fetchone()[0]
cursor.execute("""select percentage from president where ID =%s""",(i,))
percent = cursor.fetchone()[0]
tree.insert("", i, text=i, values=(nm, vot, percent)),
tree.pack()
root.mainloop()
`