摘要:
__getitem__的作用是让对象class拥有迭代功能,这样就可以使用,__表示私有方法 class Animal: def __init__(self, animal_list): self.animals_name = animal_list def __getitem__(self, in 阅读全文
posted @ 2020-08-15 10:00
Peskin
阅读(545)
评论(0)
推荐(0)
摘要:
class Base(object): def __init__(self): print ("enter Base") print ("leave Base") class A(Base): def __init__(self): print ("enter A") Base().__init__ 阅读全文
posted @ 2020-08-10 21:13
Peskin
阅读(132)
评论(0)
推荐(0)
摘要:
可以认为lambda就是定义函数的一个简洁形式 g = lambda x:x+1这里可以认为g是一个函数,x为自变量,x+1就是函数的表达式。称之为匿名函数。 lambda的三个使用地方: foo = [2, 18, 9, 22, 17, 24, 8, 12, 27] print filter(la 阅读全文
posted @ 2020-08-10 15:05
Peskin
阅读(96)
评论(0)
推荐(0)
浙公网安备 33010602011771号