Class attributes and static attributes

1. Class attributes are modified by class methods, the format @classmethod can be accessed by both class and instance.

2. The method of brackets static property without () parameter of the self, decorated by @staticmethod, by the class method names and instance method name mode access.

 

 

3. The instance method needs to add the parameter self (used to modify the instance implementation and class attributes), the class method needs to add the parameter cls (used to modify the class attributes), the static method does not need to add any parameters, and has nothing to do with the class attributes and static attributes.

 

Guess you like

Origin www.cnblogs.com/zxc01/p/12738243.html