题解 | #判断布尔值#
判断布尔值
https://www.nowcoder.com/practice/b8c8a1c5f57b4724a1cbc12eb50378a5
temp = bool(int(input()))
if temp:
print("Hello World!")
else:
print("Erros!")
首先进行输入,然后变成整出,然后bool是将输入的东西变成布尔值
if temp: 语句检查 temp 的值。如果 temp 是 True(意味着用户输入的是非零值),则执行 print("Hello World!")。


查看25道真题和解析