2017-04-21 73 views

回答

1

正如this question提到的,按位&(和)和|(或)为bool变量做工精细:

foo = False 
foo |= True 
assert foo == True == False | True == False or True 

当不使用就地运营商,它更习惯使用逻辑andor运营商。使用布尔运算符上的位运算符可能会令人困惑,因为例如~True-2,而不是False