我不断收到此错误。我没有在代码中使用任何str。有人知道是什么问题吗?
def edit_profile_emp():
username1 = username_verify.get()
password1 = password_verify.get()
full_name1 = full_name_verify.get()
faculty1 = c.get()
position1 = position_verify.get()
email1 = email_verify.get()
room_no1 = room_no_verify.get()
if full_name1 == "" and faculty1 == "" and position1 == "" and email =="" and room_no1 == "":
Label(screen_edit, text = "Please complete your profile", fg = "red")
else:
mycursor.execute("UPDATE profile SET Faculty = %s AND Position = %s AND Email = %s AND Room_NO = %s WHERE username =%s and password=%s"(username1,password1,full_name1, faculty1, position1, email1, room_no1))
connection.commit()
if mycursor.fetchone() is not None:
Label(screen_edit, text = "").pack()
Label(screen_edit, text ="CHANGES SAVED SUCCESFULLY!!", fg = "red").pack()
homepage_employee()
答案 0 :(得分:0)
您的错误很简单。在else:
函数的if
部分中,编写mycursor.execute("UPDATE
...,这是发现错误的地方。我认为解决此问题的最简单方法是用以下这段代码替换该行:
formatting=(username1, password1, full_name1, faculty1, position1, email1, room_no1)
execute_function="UPDATE profile SET Faculty = %s AND Position = %s AND Email = %s AND Room_NO = %s WHERE username =%s and password=%s"
mycursor.execute(execute_function % formatting)
有关详细信息,请参阅this website。