标签:red 继承 object self ase class sel pre init
class Lz(object):
def __init__(self):
self.money=1000000000000
self.house=‘大别野‘
def sing(self):
print(‘唱歌‘)
def dance(self):
print(‘跳广场舞‘)
def lm(self):
print(‘找朋友‘)
class Zlz(Lz):
def dance(self):#重写了父类的方法,那么已当前的为准
print(‘霹雳舞‘)
class Base(object):
def __init__(self,host,port,password):
self.host=host,
self.port=port,
self.password=password
class MySql(Base):
pass
class Redis(Base):
pass
zx=Zlz()
zx.sing()#可以直接调用父类的方法
zx.dance()
print(zx.money)
标签:red 继承 object self ase class sel pre init
原文地址:https://www.cnblogs.com/irisx/p/9063397.html