【发布时间】:2022-07-26 23:12:23
【问题描述】:
当我用python写这个时,它只能给我同样的答案。谁能帮忙??
today = 'Saturday'
if today!='Sunday' or today!='Saturday':
print('Rest')
else:
print('Work')
输出
Rest
【问题讨论】:
-
使用
|而不是or。
当我用python写这个时,它只能给我同样的答案。谁能帮忙??
today = 'Saturday'
if today!='Sunday' or today!='Saturday':
print('Rest')
else:
print('Work')
输出
Rest
【问题讨论】:
| 而不是or。
如果两个(或多个)条件中的至少一个为真,则运算符“或”返回真,因此如果您希望所有条件都为真 - 使用运算符“和”
【讨论】: