为什么这个'except:'行抛出语法错误?

问题描述:

我在做数据库的东西,我有这样的代码为什么这个'except:'行抛出语法错误?

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 

这究竟是为什么?如果您需要更多信息,我可以发布更多代码。

谢谢!

+4

标准过程中,您没有得到:回去线,检查你的括号。 – user2357112

+0

这是一个好主意,我会牢记这一点。谢谢! – Azhraam

你缺少一个括号中的语法错误

cursor.execute("INSERT INTO POST (res_post_id) where post_id = '%s';" % (temp_str, res_posts(1)))###<---Here 
+0

哈哈,我看着那条线,但没有注意到我的错误。非常感谢你! – Azhraam