python类的问题 大佬我这哪里出错了 总显示my_dog = Dog('whille',47) Dog() takes no arguments
classDog():def_init_(self,name,age):"""初始化属性name和age"""self.name=nameself.age=agedefs...
class Dog():
def _init_(self,name,age):
"""初始化属性name和age"""
self.name = name
self.age = age
def sit(self):
print(self.name.title() + 'is now sitting')
def roll_over(self):
print(self.name.title() + 'rolled over')
my_dog = Dog('whille',47)
print("my dog's name is" + my_dog.title()+'.') 展开
def _init_(self,name,age):
"""初始化属性name和age"""
self.name = name
self.age = age
def sit(self):
print(self.name.title() + 'is now sitting')
def roll_over(self):
print(self.name.title() + 'rolled over')
my_dog = Dog('whille',47)
print("my dog's name is" + my_dog.title()+'.') 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询