python面对对象(不全解)
面对对象:以人类为例,人类通用功能:吃喝拉撒,就可以封装成一个类,不同功能:嫖赌毒,就是对象的不同功能。继承,多态…
上码
class Person(object):
def __init__(self,eat,dink,la):
self.eat=eat
self.dink=dink
self.la=la
print('构造方法')
def __call__(self,*args,**kwargs):
print("类直接调用")
def public(self):
print("实例方法")
def __private(self)
print('私有方法')
@classmethod
def classmt(cls):
print('类方法')
@staticmethod
def statimt()
print('静态方法)
class Jpanese(Person):
# 继承
def __init__(self,eat,dink,la,piao,du,Du):
super(Jpanese,self).__init__(eat,dink,la)
# Person.__init__(self,eat,dink,la)
self.piao=paio
self.du=du
self.Du=Du
print("重构父类构造方法")
def public(self):
super(Jpanese,self).public()
print("继承并重构父类public方法")
ps:有错误之处,望不吝指教