一、类的初始化:为什么用__init__(self)不直接写变量赋值1.用__init__(self)可控制属性变量2.__init__(self)自动执行代码,初始化类
class CocaCola: formula = ['caffeine','sugar','water','soda'] def __init__(self): for element in self.formula: print('Coke has {}!'.format(element)) def drink(self): print('Energy!')coke = CocaCola()二、类的超继承class father: def jiachan(self): print(jin,yin,zhubao)class son(father): def jiachan(self): super(son,self).jiachan()三、list的删除list=[1,2,3,4,5]1.del按索引删除列表的元素,del.list[1]2.pop按索引取出元素的值可以赋值。无索引默认删除最后一个,list.pop[1]3.remove按值删除列表里的值,list.remove("1")