# -*- coding: utf-8 -*- #python 27 #xiaodeng #继承 class MyData(): def __init__(self,name,phone): self.name=name self.phone=phone def updatephone(self,newphone): self.phone=newphone print 'new phone is:',self.phone class MyD(MyData):#MyData是父类 def __init__(self,name,phone,id,em): MyData.__init__(self,name,phone) self.empid=id self.email=em def updateEmail(self,newem): self.email=newem print self.email if __name__=='__main__': data=MyD('xiaodeng',10086,1,'163.com') data.updatephone(95555) data.updateEmail('126.com')