0
C:\Python34\python.exe C:/Users/Stig/Desktop/python/main.py
File "C:/Users/Stig/Desktop/python/main.py", line 9
if(query.execute("SELECT * FROM 'USERS' where 'username'" + `username` + "' AND `password`='" + `password`)):
^
SyntaxError: invalid syntax
Code:語法錯誤:在Python mysql的登錄無效語法
import MySQLdb
from tkinter import *
root = Tk()
def makeLoggedInWindow():
if(query.execute("SELECT * FROM 'USERS' where 'username'", 'username', "' AND `password`='", 'password', "'")):
window = Tk()
db.commit()
label_3 = Label(window, text="Du er nu logget ind!")
label_3.pack()
else:
db.commit()
print ("Login fejlede!")
label = Label(root, text="Velkommen til mit log ind script!")
db = MySQLdb.connect(host="localhost",
user="root",
db="users")
query = db.cursor()
loop = 'true'
label_1 = Label(root, text="Username: ")
label_2 = Label(root, text="Password: ")
username = Entry(root)
password = Entry(root, show='*')
button_1 = Button(root, text="Log ind!", command=makeLoggedInWindow)
label_1.pack()
label_2.pack()
username.pack()
password.pack()
button_1.pack()
root.mainloop()
能有人幫助?
請張貼代碼內聯,而不是作爲一個鏈接 – EdChum
但我的代碼是長 – AutKix
請仔細閱讀本:http://stackoverflow.com/help/mcve – EdChum