【发布时间】:2020-11-07 22:02:15
【问题描述】:
我正在尝试制作一个程序,以便用户可以输入一个国家/地区,并且该程序可以使用 tkinter 和 sqlite 3 输出整行信息。这是我到目前为止的代码,如果你看到任何其他的请告诉我我的代码中有漏洞,提前谢谢你! :)
from tkinter import *
bobert=Tk()
bobert.geometry("600x600")
import sqlite3
connection = sqlite3.connect('covidproject.db')
cursor = connection.cursor()
country_name=StringVar()
label1=Label(bobert,text="World Covid Stats",fg="black",font=("sand script",20))
label1.place(x=183,y=100)
label2=Label(bobert,text="Name of Country:",fg="black",font=("sand script",15))
label2.place(x=130,y=150)
n=Entry(bobert,textvariable=country_name)
n.place(x=310,y=158)
def subby():
answer=country_name.get()
cursor.execute("SELECT * FROM covid WHERE name LIKE '"+answer+"'")
data=cursor.fetchall()
submit=Button(bobert, text="SUBMIT", fg="black",font=("arial",13),command=subby)
submit.place(x=260,y=200)
bobert.mainloop
【问题讨论】:
-
每当您询问特定内容时,请始终添加您遇到的错误
-
你能描述一下你的桌子吗?还要注意你的代码的最后一行,你说
bobert.mainloop() -
该表有一堆国家的名称,covid 病例数,死亡,康复,活跃和确认
标签: python database sqlite tkinter