class Birthday:
def __init__(self, year, month, day):
self.year = year
self.month = month
self.day = day
def get_birthday(self):
print('The birthday is %s %s %s'%(self.year, self.month, self.day))
class People:
country = 'China'
def __init__(self, name, age):
self.name = name
self.age = age
def tell_info(self):
print('Name is %s, the age is %s'%(self.name, self.age))
class People1(People):
def __init__(self, name, age, sex, hobby):
super().__init__(name, age)
self.sex = sex
self.hobby = hobby
def tell_info(self):
super().tell_info()
print('the gender is %s, the hobby is %s' % (self.sex, self.hobby))
p = People1('Raimond', 18, 'male', 'reading')
p.tell_info()
p.birth = Birthday('1990', '05', '20')
p.birth.get_birthday()
C:\Users\user\AppData\Local\Programs\Python\Python36\python.exe “C:/Users/user/PycharmProjects/hellow python/test.py”
Name is Raimond, the age is 18
the gender is male, the hobby is reading
The birthday is 1990 05 20
Process finished with exit code 0