我对python编程有点陌生,但我做了以下代码:
dimValue = 0
。。。。。。。。你知道吗
elif event[0] == "control" and body["location"] == location and body["action"] == "on":
auxValue = int(body["dim"])
print("AuxValue = " + str(auxValue))
if auxValue > dimValue:
print("entrou")
dimControl=auxValue-dimValue
print("DimControl = " + str(dimControl))
dimValue = auxValue
os.system("heyu bright A1 "+ str(dimControl))
elif dimValue > auxValue:
print("saiu")
dimControl=dimValue-auxValue
dimValue = auxValue
os.system("heyu dim A1 "+ str(dimControl))
使用此代码,如果int(body[“dim”])是5,则只显示第一次打印,而不输入if else语句。如果我注释这行“dimValue=auxValue”,它将进入If else,并做好每件事。但我需要把这条线。我做错了什么?你知道吗
谢谢。你知道吗
雨果席尔瓦
听起来好像既没有输入
if
块,也没有输入elif
块。当auxValue等于dimValue时可能会发生这种情况;然后两个条件的计算结果都不是true。您可以将>;更改为>;=或将<;更改为<;=,具体取决于它们相等时要运行的块。你知道吗相关问题 更多 >
编程相关推荐