语法糖

@classmethod 标识类方法,第一个参数自动绑定到自身类对象(cls),可通过cls 访问类中对象

@staticmethod 静态方法

class bi():
    @staticmethod
    def info():
        print("log:mmm")
        
    @classmethod
    def uu(cls,t):
        print("88888:{}".format(t))

@property  属性装饰: 设置只读属性、重写属性set、get

class student(object):
    def __init__(self, name, score):
        self.name = name
        self.__score = score
    @property   #get score
    def score(self):
        return self.__score
    @score.setter
    def score(self, score):   #set score
        assert  score >= 0 and score <= 100
        self.__score = score
        
s = student("jems",60)      
原文地址:https://www.cnblogs.com/moonypog/p/11065599.html