20044031
2021-01-22 18:49
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)
Python3 进阶教程(新版)
41910 学习 · 236 问题
相似问题