考虑以下...
In [1]: del []
In [2]: del {}
File "<ipython-input-2-24ce3265f213>", line 1
SyntaxError: can't delete literal
In [3]: del ""
File "<ipython-input-3-95fcb133aa75>", line 1
SyntaxError: can't delete literal
In [4]: del ["A"]
File "<ipython-input-5-d41e712d0c77>", line 1
SyntaxError: can't delete literal
有什么特别之处[]
?我希望这也会提高SyntaxError
。为什么不呢?我在 Python2 和 Python3 中观察到了这种行为。