Python 3.8.5(default, Sep 42020,07:30:14)[GCC 7.3.0]:: Anaconda, Inc. on linux
Type "help","copyright","credits"or"license"for more information.>>> x =[]>>> y =[]>>>if(len(x)==0)|len(y)==0:...print("t")...>>>if(len(x)==0)|(len(y)==0):...print("t")...
t
>>>if(len(x)==0)orlen(y)==0:...print("t")...
t
>>>
Python中 “ & ” 与 “ | ”、“ and ”,“ or ”的区别 a&b、a|b: 当a和b同时为数字时,“&”、“|”是位运算符,
lx@master:~$ python
Python 3.8.5(default, Sep 42020,07:30:14)[GCC 7.3.0]:: Anaconda, Inc. on linux
Type "help","copyright","credits"or"license"for more information.>>># 6 的二进制是110>>># 1 的二进制是1>>>6&10>>>6|17>>># &
KeyboardInterrupt
>>># ‘&’是且的意思,而“|”是或的意思,且是同真则真,否则为假。或是相异为1,相同为0 >>>