# encoding:utf-8
class animal(object):
def __init__(self,name,age):
self.name = name
self.age = age
def get(self):
print(self.name,self.age)
dog = animal("汪汪",3)
cat = animal("喵喵",2)
dog.get()
cat.get()
class animal(object):
def __init__(self,name,age):
self.name = name
self.age = age
def get(self):
print(self.name,self.age)
dog = animal("汪汪",3)
cat = animal("喵喵",2)
dog.get()
cat.get()
2020-12-02
例子中引用循环变量返回值为函数,所以会受到循环变量变化影响,任务中将返回值进行实际赋值,后续变量产生变化不对已赋值变量产生影响,不知道这么理解对不对
2020-09-24
#set方法作用,i guess
Animal('1', 1, '1')
print(dog.get_info())
dog.set_info('2',2,'2')
print(dog.get_info())
Animal('1', 1, '1')
print(dog.get_info())
dog.set_info('2',2,'2')
print(dog.get_info())
2020-09-23
L1 = ['bob', 'about', 'Zoo', 'Credit']
L2 = sorted(L1,key=str.lower)
print(L2)
L2 = sorted(L1,key=str.lower)
print(L2)
2020-09-18