Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

这代码真的是要气死人啊?! #72

Open
feiyihx opened this issue Jan 4, 2024 · 0 comments
Open

这代码真的是要气死人啊?! #72

feiyihx opened this issue Jan 4, 2024 · 0 comments

Comments

@feiyihx
Copy link

feiyihx commented Jan 4, 2024

到底为什么会把布尔值当作字符串的值啊?!
在示例代码里面,以下这段话根本无法进行电源状态变更,因为pState是一个字符串而返回值是"true"和”false“
首先,按照代码里面的on和off是根本就没判断。
其次,按照代码逻辑,返回值是真假应该是布尔变量直接判断也不行。
也就是说,非得把布尔值当作字符串用。
什么情况啊,示例代码不按照代码规范写还是个出错不能运行的。

set_state = message.data["pState"]
print("change power state to : {0}".format(set_state))

if set_state == "on":
    pass
elif set_state == "off":
    pass

也就是说这段代码正常运行应该是这样的:

set_state = message.data["pState"]
print("change power state to : {0}".format(set_state))

if set_state == "true":
    pass
elif set_state == "false":
    pass

https://github.com/blinker-iot/blinker-py/blob/dev_3.0/example/voice_assistant.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant