我正在从配置为Input的通用IO(GPIO)中读取一个值,它返回一个0或1的字符串.我看到两种简单的方法将它转换为boolean:
bool(int(input_value))
Run Code Online (Sandbox Code Playgroud)
要么
not not int(input_value)
Run Code Online (Sandbox Code Playgroud)
哪个是Pythonic?有更多的Pythonic方式,然后上面提到的方式?
python ×1