📜  为什么静态 kwyword 不在 python 代码示例中

📅  最后修改于: 2022-03-11 14:47:15.108000             🧑  作者: Mango

代码示例1
Variables declared inside the class definition, but not inside a method are class or static variables:

>>> class MyClass:
...     i = 3
...
>>> MyClass.i
3 
As @millerdev points out, this creates a class-level i variable, but this is distinct from any instance-level i variable, so you could have

>>> m = MyClass()
>>> m.i = 4
>>> MyClass.i, m.i
>>> (3, 4)