【发布时间】:2020-12-04 22:28:22
【问题描述】:
此代码从表中检索所有记录并显示。我怎样才能改变它,使它一次只显示表中的一条记录?
def printquestion():
conn = sqlite3.connect('VIT.db')
c = conn.cursor()
posts = "select que from Questions"
c.execute(posts)
conn.commit()
records = c.fetchall()
print(records)
print_q = ''
for record in records:
print_q += str(record[0]) + "\n"
lbl_question = Label(top, text=print_q)
lbl_question.grid(row=2, column=1)
conn.close()
【问题讨论】:
-
“一次显示一条记录”是什么意思?您使用的是什么 GUI 框架?它是桌面应用还是网络应用?
-
我正在使用 python 和 tkinter。它适用于桌面应用程序。通过“一次显示一条记录”,我的意思是我需要从我所指的表中访问一条记录。表中有几条字符串形式的记录。单击按钮后,我需要它们一一出现。顺便说一句,我对 python 很陌生,请原谅我缺乏知识。