错误在哪里?我所做的一切与视频教程/书籍中的相同,没有出现错误。当然,也许还有另一个版本的python。我怎么了?
class Dog():
"""Simple dog model"""
def _init_(self,name, age):
"""Initialize attributes, name and age"""
self.name = name
self.age = age
"""Dog created"""
def sit(self):
"""The dog will sit down on command"""
print(self.name.title()+ " the dog sat down")
def jump():
"""The dog will jump on command"""
print(self.name.title()+" the dog jumped")
my_dog = Dog()
print(my_dog.name)
我得到:
Traceback (most recent call last):
File "C:/Users/Professional/PycharmProjects/thebasics/exmplclass.py", line 22, in <module>
my_dog = Dog('topik',5)
TypeError: Dog() takes no arguments
Process finished with exit code 1