为什么 Python 为"True 和 1"表达式返回 1?还是 False 表示"False and 1"?



我是学习编程的新手,我是自学的,所以我非常感谢你的回答。 :)

>>> True and 1
1
>>> False and 1
False
False 是 ">

falsy" 值,True 是 "truey" 值。 Truthy是具有"Truth"(类似Truth(的值。 Falsy是一个具有虚假性(假样(的值。此外,1 是真值,0 是假值。 翻译你的表达方式会给我们留下"真实和真实","法斯利和真实"。

基于基本的布尔逻辑,Truthy and Truthy TrueTruthy and Falsy False. 最后,根据上一段,以下所有条件都是平等的:

1 and True, True and True
False or 1, False or True
0 and 0, False and False
1 and 0, True and False

最新更新