我已经尝试了很多方法,但我似乎无法弄清楚,但无论如何这就是我正在做的事情:
threadupdatequery = "UPDATE %s SET topic_name=%%s, subject_name=%%s, poster_name=%%s, time=%%s, image=%%s, replies=%%s, id=%%s, keywords=%%s, text=%%s WHERE id=%%s" % ('Threads')
...
(topic, subject, name, time, image, replies, ID, kw, body) = self.tframe.Get()
cur.execute(threadupdatequery, (topic, subject, name, time, image, replies, ID, kw, body))
最初我这样做是毫无疑问会起作用的,但我错了:
cur.execute(threadupdatequery, self.tframe.Get())
我不断得到:
File "C:\Python27\Work\SiteEditor.py", line 216, in UpdateThread
cur.execute(threadupdatequery, (topic, subject, name, time, image, replies, ID, kw, body))
File "C:\Python27-32Bit\lib\site-packages\MySQLdb\cursors.py", line 184, in execute
query = query % db.literal(args)
TypeError: not enough arguments for format string
我到底做错了什么?通常我会犯一些愚蠢的错误,但这次我看不到它......
谢谢 :)