Python class and inheritance, the preliminary understanding, where the 12th line CALSS people () add no company is the same, this is not understood.
classCompany :def __init__(self,name,birthyear,birthmonth,birthplace): Self.name=name Self.birthyear=birthyear Self.birthmonth=Birthmonth Self.birthplace=Birthplacedefdesc (self):Print('%s was created in%d%d months and was born in {0}'. Format (self.birthplace)%(self.name,self.birthyear,self.birthmonth))Print('{ 0} was created in {1} year {2} month, born in {3}'. Format (self.name,self.birthyear,self.birthmonth,self.birthplace))Print(Self.name,'created in', Self.birthyear,'years', Self.birthmonth,'Month','Born in', Self.birthplace)classPeople (company):def __init__(self,name,birthday,birthmonth,birthplace): Company.__init__(Self,name,birthday,birthmonth,birthplace)defdesc (self):Print('{ 0} was born in {1} years {2} months, {3} people'. Format (Self.name, Self.birthyear, Self.birthmonth, Self.birthplace)) C=company ('Blog Park', 2004, 1,'Yangzhou, Jiangsu') C.desc () p=people ('Chen Duxiu', 1879, 10,'Anqing, Anhui') P.desc ()
Operation Result:
Founded in January 2004, the blog Park was born in Yangzhou, Jiangsu province.
Founded in January 2004, the blog Park was born in Yangzhou, Jiangsu province.
Founded in January 2004, the blog Park was born in Yangzhou, Jiangsu Province
Chen Duxiu was born in October 1879, Anhui anqing people
Back again to learn the post.
Python class and inheritance, inheritance is not quite understood, first put a piece of code