小编Jer*_*hez的帖子

IndexError:元组索引超出范围----- Python

请帮我.我正在运行一个简单的python程序,它将以tkinter形式显示mySQL数据库中的数据...

from Tkinter import *
import MySQLdb

def button_click():
    root.destroy()

root = Tk()
root.geometry("600x500+10+10")
root.title("Ariba")

myContainer = Frame(root)
myContainer.pack(side=TOP, expand=YES, fill=BOTH)

db = MySQLdb.connect ("localhost","root","","chocoholics")
s = "Select * from member"
cursor = db.cursor()
cursor.execute(s)
rows = cursor.fetchall()

x = rows[1][1] + " " + rows[1][2]
myLabel1 = Label(myContainer, text = x)
y = rows[2][1] + " " + rows[2][2]
myLabel2 = Label(myContainer, text = y)
btn = Button(myContainer, text = "Quit", command=button_click, height=1, width=6)

myLabel1.pack(side=TOP, expand=NO, fill=BOTH)
myLabel2.pack(side=TOP, expand=NO, …
Run Code Online (Sandbox Code Playgroud)

python mysql-python python-2.7

34
推荐指数
2
解决办法
28万
查看次数

标签 统计

mysql-python ×1

python ×1

python-2.7 ×1