我正在做数据库事情,我有这个代码
for res_posts in list_of_response_ids:
temp_str = res_posts[0] # first element of res_posts tuple is string
temp_str += ":" + output
try:
cursor.execute("INSERT INTO POST (res_post_id) where post_id = '%s';" % (temp_str, res_posts(1))
except:
print "life sucks"
db.close()
抛出语法错误:
$ python post.cgi
File "post.cgi", line 85
except:
^
SyntaxError: invalid syntax
为什么会这样?如果您需要更多信息,我可以发布更多代码。
谢谢!
答案 0 :(得分:3)
你缺少一个括号
cursor.execute("INSERT INTO POST (res_post_id) where post_id = '%s';" % (temp_str, res_posts(1)))###<---Here