创建 Student() 实例时,它显示类型错误,super()。init (self,name,age,gender,address) TypeError: init () 接受 5 个位置参数但给出了 6 个 我尝试了很多方法但我没有成功。请帮我解决这个问题!!!
def __init__(self, house_name,street,dist,state,pin,country='India'):
self.house_name = house_name
self.street = street
self.dist = dist
self.state = state
self.pin = pin
self.country = country
class Person:
CURR_ID = 0
def __init__(self,name,age,gender,address):
self.id = None
self.name = name
self.age = age
self.gender = gender
self.address = []
self.add_address(address)
self.set_id()
def add_address(self,address):
if not isinstance(address, Address):
raise ValueError('Invalid address...')
elif isinstance(address,list):
for entry in address:
if not isinstance(address, Address):
raise ValueError('Invalid address...')
self.address.append(entry)
self.address = address
return True
def set_id(self):
self.id = Person.CURR_ID + 1
Person.CURR_ID += 1
def get_id(self):
return self.id
class Student(Person):
def __init__(self,name,age,gender,address):
super().__init__(self,name,age,gender,address)
self.max_enroll = False
self.course_enrolled = []
if __name__ == '__main__':
s1 = Student('Student', 24,'M',Address('HouseName','Street','Dist','State', '112233'))
print(s1.__dict__)```