【面向对象】类的三大特性 (5)

相关补充

class Foo: def func(self): print(\'in father\') class Son(Foo): def func(self): print(\'in son\') s = Son() s.func() #in son 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()

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zwyjwz.html