摘要: python定义一个类 类中可以有 对象方法、类方法、静态方法 对象方法: 我们可以通过类创建实例,这个过程叫做实例化,创建出的对象叫做类的实例,对象的属性叫做实例属性,对象的方法叫做对象方法或实例方法 对象方法:默认有个self参数,可以操作实例属性和类属性 ,只能被实例对象调用。 class T 阅读全文
posted @ 2020-10-11 14:13 learningcaiji 阅读(359) 评论(0) 推荐(0) 编辑
摘要: python中要想得到一个列表(list)的长度,通常使用 len()函数即可实现,是因为在类list,dict,set,tuple,str中内置了__len()__方法 print('__len__' in dir(list))True # 证明__len__这个方法在类list,dict,set 阅读全文
posted @ 2020-10-11 10:54 learningcaiji 阅读(679) 评论(0) 推荐(0) 编辑