我不断收到此错误。我没有在代码中使用任何字符串。有人知道是什么问题吗?

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()

最佳答案

您的错误很简单。在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

关于python - TypeError:'str'对象不可调用-Python,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58147486/

10-16 14:17