我在第89行收到SyntaxError:语法无效(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)可以在以下位置找到:链接到GitHub存储库
它旨在在MySQL数据库和alamode(arduino)之间传递信息。
在该行上方,您有一个try
没有except
跟随任何块的块。这就是为什么您应该在问题中张贴整个代码的原因。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句