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):
People.__init__(self, name, age)
self.sex = sex
self.hobby = hobby
def tell_info(self):
People.tell_info(self)
print('the gender is %s, the hobby is %s' % (self.sex, self.hobby))
p = People1('Raimond', 18, 'male', 'reading')
p.tell_info()
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
Process finished with exit code 0