[英]Why is this 'except:' line throwing a syntax error?
我正在做數據庫的事情,我有這段代碼
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
為什么會這樣呢? 如果您需要更多信息,我可以發布更多代碼。
謝謝!
您缺少括號
cursor.execute("INSERT INTO POST (res_post_id) where post_id = '%s';" % (temp_str, res_posts(1)))###<---Here
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.