摘要: class Stuent(object): stu_num = 0 __stu_num = 0 name = 333 def __init__(self,name): self.name = name # self.stu_num += 1 # 这就相当于对实例进行了赋值 Stuent.stu_nu 阅读全文
posted @ 2022-10-23 16:00 Stary_tx 阅读(24) 评论(0) 推荐(0) 编辑
摘要: #类方法通过@classmethod 装饰器实现# 类方法和普通方法的区别是,类方法只能访问类变量,不能访问实例变量class Dog(): name = "stupid_dog" def __init__(self,name): self.name = name @classmethod def 阅读全文
posted @ 2022-10-23 10:40 Stary_tx 阅读(33) 评论(0) 推荐(0) 编辑