calss Animal(object):
def_init_(self,name,age)
self.name = name
self.age = age
dog = Animal()
cat = Animal()
dog.name = 'Tim'
dog.age = 4
cat.name = 'Aim'
cat.age = 5
print(dog.name)
print(dog.age)
print(cat.name)
print(cat.age)
calss Animal(object): def __init__(self,name,age) self.name = name self.age = age dog = Animal('Tim',4) cat = Animal('Aim',5) print(dog.name) print(dog.age) print(cat.name) print(cat.age)
class Animal(object):#class 拼写错误 def __init__(self,name,age):#冒号丢失 self.name = name self.age = age dog = Animal('Tim',4) cat = Animal('Aim',5) print(dog.name) print(dog.age) print(cat.name) print(cat.age)