class Person: def __init__(self,name,PID,sex,age): self.name=name self.PID=PID self.sex=sex self.age=age def getname(self): return self.name def getPID(self): return self.PID def getsex(self): return self.sex def getage(self): return self.age def getinfo(self): return self.name,self.PID,self.sex,self.age def setname(self,name): self.name=name def setID(self,PID): self.PID=PID def setsex(self,sex): self.sex=sex def setage(self,age): self.age=agedef setinfo(self,name,PID,sex,age): self.name=name self.PID=PID self.sex=sex self.age=age class Ustudent(Person): #重写构造函数 def __init__(self,name,PID,sex,age,school): super().__init__(name,PID,sex,age) self.school=school def getschool(self): return self.school #重写 getinfo 函数 def getinfo(self): return self.name,self.PID,self.sex,self.age,self.school #重写 setinfo 函数 def setinfo(self,name,PID,sex,age,school): #self.name=name #self.PID=PID #self.sex=sex #self.age=age super().setinfo(name,PID,sex,age) def setschool(self,school): self.school=school p=Person("zjhong","3307217305256314","M",19) print(p.getinfo()) s=Ustudent("zjh","3307217305256313","M",20,"湖州师院学院") p.setinfo("zhangjh","3307217305256315","F",18) print(s.getinfo()) print(p.getinfo()) s.setinfo("zhangjianh","3307217305256316","F",21,"湖州学院") print(s.getinfo()) #调用父类继承函数 setname s.setname("lisi") s.setschool("湖州师范学院") print(s.getinfo()) print(p.getinfo())