@classmethod 和 @staticmethod 用法

class A:
    __role = 'CHINA'
    @classmethod
    def show_role(cls):
        print(cls.__role)

    @staticmethod
    def get_role():
        return A.__role

    @property
    def role(self):
        return self.__role

a = A()
print(a.role)
print(a.get_role())
a.show_role()
posted on 2019-11-13 16:37  Test-Billy  阅读(96)  评论(0编辑  收藏  举报