def __init__(self,name,age,native):
self.name name #实例变量 #只能对应的实例对象进行访问
self.age age #实例变量 #只能对应的实例对象进行访问
self.__Native native #私有实例变量
def business(self): #公有 #成员方法 #实例方法
print(self.__college) #在内部访问私有类变量
def mthod(self):
print( 我是公有成员方法 )
def __mthood(self): #私有方法
print( 我是私有方法 )
def mthhood(self):
self.mthod()
self.__mthood() #在内部访问私有变量
classmethod
def leimthod(cls):
print( 我是类方法 )
staticmethod
def jtmthod():
print( 我是静态方法 )
def mtod(self):
self.leimthod() #内部调用
self.jtmthod()
if __name__ __main__ :
t person( abc ,12,15) #实例化一个对象
t.school #可以直接访问
person.school #可以直接访问类变量
t.name #可以直接访问
t.mthhood()
t.mtod()
t.business()
#静态方法和类方法可以通过类名和对象名调用
t.leimthod()
t.jtmthod()
person.leimthod()
person.jtmthod()