将布尔值与==Python中的工作进行比较.但是当我应用布尔not运算符时,结果是语法错误:
Python 2.7 (r27:82500, Sep 16 2010, 18:02:00)
[GCC 4.5.1 20100907 (Red Hat 4.5.1-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> True == True
True
>>> False == False
True
>>> True is not False
True
>>> True == not False
File "<stdin>", line 1
True == not False
^
SyntaxError: invalid syntax
>>>
Run Code Online (Sandbox Code Playgroud)
为什么这是语法错误?我希望not False是一个返回布尔值的表达式,并且True == <x>只要<x>是具有有效语法的表达式,它就是有效的语法.