我在下面代码的最后一行使用sqlite3和Python有一个语法问题:
playerName = input("Enter your name: ")
money = input("Enter credits: ")
conn = sqlite3.connect("highscore.db")
c = conn.cursor()
c.execute("CREATE TABLE players(name TEXT, money INTEGER)")
c.execute("INSERT INTO players VALUES('%s','%s')", playerName, money)
我该如何解决这个问题?
答案 0 :(得分:0)
更改此行:
c.execute("INSERT INTO players VALUES('%s','%s')", playerName, money)
要:
c.execute("INSERT INTO players VALUES(?,?);",(playerName, money))