嗨,我有以下超级类
class Room:
def __init__(self,building,floor,number):
self.building=building
self.floor=floor
self.number=number
def __str__(self):
return (str(self.building)+'.'+str(self.floor)+'.'+str(self.number))
和以下子类
class Occupant(Room):
def __init__(self,familyname,givenname,building,floor,number):
self.familyname=familyname
self.givenname=givenname
Room.__init__(self,building,floor,number)
def __str__(self):
return (str(self.familyname)+', '+str(self.givenname)+......)
子类如何打印超类中的元素。当我从类 Occupant 打印对象时,我应该添加到(.....)以获取正确的输出。谢谢