我正在尝试在Python中为登录屏幕添加一个简单的检查,但它不起作用。我是初学者所以请帮助我理解我做错了什么。以下是检查和相关的依赖关系。
colors.xml
登录初始化:
def check():
global un, pwd, login, l, root
u=un.get()
p=pwd.get()
l.execute("select * from log")
for i in l:
if i[0]==u and i[1]==p and u=='admin':
root.destroy()
open_win()
elif i[0]==u and i[1]==p:
root.destroy()
open_cus()
elif i[0]==u or i[1]==p:
top=Tk()
Label(top,width=30, text='Wrong Password or Username').grid(row=0, column=0)
top.mainloop()
login.commit()
def main_menu(): #controls open and close of main menu window----------------------------------------RETURN TO MAIN MENU
global sto, apt, flag, root, st, val, exp, st1,rev
if flag=='sto':
sto.destroy()
if flag=='rev':
rev.destroy()
elif flag=='st':
st.destroy()
elif flag=='st1':
st1.destroy()
elif flag=='val':
val.destroy()
elif flag=='exp':
exp.destroy()
elif flag=='d':
d.destroy()
open_win()
def main_cus():
global st, flag, exp
if flag=='exp':
exp.destroy()
elif flag=='st':
st.destroy()
open_cus()
def open_cus(): #OPENS MAIN MENU----------------------------------------------------------------------------MAIN MENU
global apt, flag, flags
flags='apt1'
apt=Tk()
apt.title("Interface")
Label(apt, text="MEDPLUS CHEMIST AND DRUGGIST").grid(row=0,column=0)
Label(apt, text='*'*40).grid(row=1,column=0)
Label(apt, text='* WELCOME *').grid(row=2,column=0)
Label(apt, text='-'*40).grid(row=3,column=0)
Label(apt, text="Customer Services").grid(row=4,column=0)
Label(apt, text='-'*40).grid(row=5,column=0)
Button(apt,text='Search', width=15, command=search).grid(row=6,column=0)
Button(apt,text='Expiry Check', width=15, command=exp_date).grid(row=7,column=0)
Label(apt, text='-'*40).grid(row=8,column=0)
Button(apt,text='Logout',command=again).grid(row=9, column=0)
apt.mainloop()
again()
错误:
login=sqlite.connect("admin.sqlite")
l=login.cursor()
#l.execute('''CREATE TABLE log(user, password)''')
#l.execute("INSERT INTO log VALUES ('admin','123456')")
login.commit()