我不断收到错误:
Traceback (most recent call last):
File "C:\Users\Shepard\Desktop\Final Program\TestMaker.py", line 53, in <module>
qs.AddQuestion(None, Question, Answer[1] , Answer[2], Answer[3], Answer[4], Answer[5])
TypeError: AddQuestion() takes 7 positional arguments but 8 were given
似乎很容易弄清楚。我刚刚浏览了所有查询语句并计算了七个位置参数。每次。包括身份证。这是什么黑魔法?我很迷茫,这甚至不是可笑的。
这是生成 sqlite3 查询的所有代码。
def CreateDb(self):
query = """CREATE TABLE Questions
(id INTEGER PRIMARY KEY, Question TEXT, Answer1 TEXT, Answer2 TEXT, Answer3 TEXT, Answer4 TEXT, CorrectAnswer TEXT)"""
self.cursor.execute(query)
self.connection.commit()
def AddQuestion(self, Question, Answer1, Answer2, Answer3, Answer4, CorrectAnswer):
self.cursor.execute("""INSERT INTO questions
VALUES (?, ?, ?, ?, ?, ?, ?, ?)""", [None, Question, Answer1, Answer2, Answer3, Answer4, CorrectAnswer])
self.connection.commit()
if __name__ == "__main__":
qs = QuestionStorage(testName + ".db")
qs.CreateDb()
qs.AddQuestion(None, Question, Answer[1] , Answer[2], Answer[3], Answer[4], Answer[5])
我现在很迷茫:S