第89行的语法错误

时间:2014-10-12 22:33:50

标签: python syntax-error

我收到了SyntaxError:第89行的语法无效(insert_temp = ...)

我找不到语法错误(当注释掉时,第92行给出了相同的错误 - insert_status = ...)。有人可以帮帮我吗?我好几周都在看这个。

这是代码的特定部分,语法错误。

# Pass temps & status to db

insert_temp = """INSERT INTO current_temp(DATE_TIME, IN_TEMP, CAR_1_TEMP, CAR_2_TEMP, 
        CAR_3_TEMP) VALUES (%d, %d, %d, %d, %d) % (NOW(), i_temp, c_1_temp, c_2_temp, c_3_temp)"""

insert_status = """INSERT INTO 'status' (DATE_TIME, COOL_STATUS, HEAT_1_STATUS,
    HEAT_2_STATUS,IN_FAN_STATUS, CAR_3_FAN) VALUES (NOW(), $c_status,
    $h_1_status, $h_2_status,$i_fan_status, $c_3_fan)"""

try:
   # Execute the insert_temp command
   cursor.execute(insert_temp)
   # Commit your changes in the database
   db.commit()
except:
   # Rollback in case there is any error
   db.rollback()

try:
   # Execute the insert_status command
   cursor.execute(insert_status)
   # Commit your changes in the database
   db.commit()
except:
   # Rollback in case there is any error
   db.rollback()

完整文件(Py_Ferm_v1.py)可在以下位置找到: link to GitHub repository

它旨在在MySQL DB和alamode(arduino)之间传递信息。

1 个答案:

答案 0 :(得分:1)

您有一个try块,其后面没有except块,位于该行之上。这就是你应该在你的问题中发布整个代码的原因。

相关问题