我期待一个JSON味精变量与Python沿着这些线路进行解析,通过MQTT进来:的Python寻找在JSON
{"OPTION1": "0", "OPTION2": "50", "OPTION3": "0", "OPTION4": "0"}
根据情况的不同,这些选项可能会或可能不会进行解析通过的Python进入JSON MSG,正因为如此,它可能最终寻找为:
{"OPTION1": "0", "OPTION3": "0", "OPTION4": "0"}
并且因此跳过OPTION2和它完全值。
为了避免我的脚本borking了我,我就在想扫描如果选项是那里第一次,在设置前,像这样:
if data['OPTION1']:
>do something here<
else:
continue
然而,这似乎并没有工作,它想出:
File "listen-mqtt.py", line 28
continue
SyntaxError: 'continue' not properly in loop
任何帮助将非常感激!谢谢。
'pass'就是你要找的(不是'继续') –
'else'子句是不必要的。 https://docs.python.org/3/tutorial/controlflow.html?highlight=continue – tanglong