Home > other >  Python calls class prompt object () does not accept any parameters, such as how to solve
Python calls class prompt object () does not accept any parameters, such as how to solve

Time:03-29


The code is as follows:
The class Dog () :
Def init (self, name, age) :
The self. The name=name
The self. The age=age
Def sit (self) :
Print (self. Name. Title () + "is now sitting.")
Def roll_over (self) :
Print (self. Name. Title () + "rolled over!" )
Call the class
My_dog=Dog (' Willie, 6)
My_dog. Sit ()
Print (" My dog 's name is "+ my_dog. Self. Name. Title ())
Print (" My dog is "+ STR (my_dog. Self. Age) + years old!" " )
Prompt error is as follows:
TypeError Traceback (the most recent call last)

- & gt; 1 my_dog=Dog (' Willie, 6)
2 my_dog. Sit ()
3 # print (" My dog 's name is "+ my_dog. Self. Name. Title ())
4 # print (" My dog is "+ STR (my_dog. Self. Age) + years old!" " )
TypeError: object () takes no parameters

CodePudding user response:


Found when defining a sinkhole, data access around the init method is because it is two slip line such as __init__ ()

CodePudding user response:

Ha ha better now.thanks!
  • Related