摘要: 1.可存在同名对象 class A: def __init__(self): print('this is class.') def A(): print('this is method.') a = A() # this is method. 由于python是边编译边执行的语言,所以只会使用最近 阅读全文
posted @ 2022-10-14 17:07 Bridgebug 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 一、创建类 class People: pass p = People() 二、构造函数 __init__()方法是一种特殊的方法,被称为类的构造函数或初始化方法,当创建了这个类的实例时就会调用该方法。 python中一个类只能有一个构造函数,即只能有一个 __init__ 方法(有多个时,最后一个 阅读全文
posted @ 2022-10-14 16:52 Bridgebug 阅读(57) 评论(0) 推荐(0) 编辑