demo1
>>> print(True == 1) >>> print(True == 2) >>> print(False == 0) >>> print(False == 2) True False True False
這說明1與True,0與False在python來說是完全相等的東西。
demo2
>>> x = 5 >>> if x%2: >>> x += 1 >>> else: >>> x -= 1 >>> print(x)
在demo2中可以看出二者之間關系的妙用。
x%2=0 <——> x%2 = True
---------------------
版權聲明:本文為CSDN博主「Bruce chen」的原創文章,遵循CC 4.0 by-sa版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/cpc784221489/article/details/90721228