#2
greenpop2019-11-08 15:14
|
class Dog():
def _init_(self,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('willie',6)
print("My dog's name is "+my_dog.name.title()+".")
print("My dog is "+str(my_dog.age)+" years old.")
错误信息:
Traceback (most recent call last):
File "D:\zwg\pythonst\dog.py", line 13, in <module>
my_dog=Dog('willie',6)
TypeError: Dog() takes no arguments