Error: Typeerror:object () takes no parameters
Where?
When you use a custom class, the instance class passes arguments, prompting for this error
Why?
Because of the class instance, no arguments are required, but the class parameter is given, essentially the class has no __init__ instance method, or the __init__ instance method does not declare any parameters to be received
The same?
Check if the __init__ function is incorrectly written, Init misspelled, or whether the parameter that needs to be initialized is passed in the __INIT__ function
Error code:
Class Student (object): # init is wrong, written as int def __int__ (self, student_list): self.student_list = student_list def __getitem__ (self, item): return self.student_list[item]students = Student (["Beimenchuixue", "North gate Blowing Snow"])
Correct code:
Class Student (object): # change int to init def __init__ (self, student_list): self.student_list = student_list< C3/>def __getitem__ (self, item): return self.student_list[item]students = Student (["Beimenchuixue", "North gate Blowing Snow"])
Python-typeerror:object () takes no parameters