当我尝试使用python的not运算符检查列表是否为空时,它的行为很奇怪。
not
我尝试将not运算符与列表一起使用以检查其是否为空。
>>> a = [] >>> not (a) True >>> not (a) == True True >>> not (a) == False True >>> True == False False
的预期输出not (a) == False应为False。
not (a) == False
python list conditional-statements
conditional-statements ×1
list ×1
python ×1