标签:style blog ar color sp div log bs ef
1 class SchoolMember: 2 def __init__(self,name,age): 3 self.name = name 4 self.age = age 5 print ‘Initialized SchoolMember:%s‘%self.name 6 7 def tell(self): 8 print ‘Name:%s Age:%s‘%(self.name,self.age) 9 10 class Teacher(SchoolMember): 11 def __init__(self, name, age,salary): 12 SchoolMember.__init__(self, name, age) 13 self.salary = salary 14 print ‘Initialized Teacher:%s‘%self.name 15 16 def tell(self): 17 print ‘Salary:%d‘%self.salary 18 19 class Student(SchoolMember): 20 def __init__(self, name, age,marks): 21 SchoolMember.__init__(self,name,age) 22 self.marks = marks 23 print ‘Initialized Student %s‘%self.name 24 25 def tell(self): 26 print ‘Marks %s‘%self.marks 27 28 t = Teacher(‘Mars‘,40,3000) 29 s = Student(‘Sw‘,18,88) 30 31 t.tell() 32 s.tell()
标签:style blog ar color sp div log bs ef
原文地址:http://www.cnblogs.com/predator-wang/p/4152309.html