HongKongPython 2020-06-09
class A():
def walk(self): #实例方法,a = A()--a.walk() print(‘walking ‘) @staticmethod #静态方法, A().sta() def sta(): print(‘static func‘) @classmethod #类方法, A().classfunc() def classfunc(self): print(‘class method‘) @property #静态属性, a = A()--a.pro def pro(self): return ‘property func‘ def __privatefunc(self):#私有方法,只有内部访问 print(‘私有方法‘) def forprivatefunc(self): #内部访问私有方法 return self.__privatefunc()