python布尔之True,False与1,0的区别

python布尔之True,False与1,0的区别

版权声明:转载请随意;关注请随意^_^ https://blog.csdn.net/csdn_0_001/article/details/79269867

print(True)         # True
print(False)        # False
print(1)            # 1
print(0)            # 0

print(True==1)      # True
print(True==2)      # False 只有1是true,其他值不是
print(True==0)      # False
print(False==0)     # True
print(False==2)     # False 只有0是false,其他值不是

print(True>False)   # True
print(True>0)       # True
print(False>0)      # False
print(False<1)      # True
print(False<0)      # False

猜你喜欢

转载自blog.csdn.net/qq_34802511/article/details/82594445