为什么禁止使用名为None
的成员变量(“属性”)?
x = object()
x.y = 55
x.watermelon = "green red and white"
x.None = None
错误:
File "D:/FILE_MGMT_PYTHON/fgfghfghfgh.py", line 9
x.None = None
^
SyntaxError: invalid syntax
Process finished with exit code
发布于 2019-10-28 05:26:41
来自文档
下列标识符用作保留字或语言的关键字,不能用作普通标识符。它们的拼写必须与这里所写的完全一样: .
None
.
https://stackoverflow.com/questions/58586088
复制相似问题