类属性类方法
类属性:使用赋值语句在class关键字下定义
类方法:在类内部可以直接访问雷属性或者其它类方法
class student(objict):
count = 0
def init(self,name):
self.name = name
student.count += 1
@classmethod
def show_student_count(awda):
print('student number is %d' %(awda.count))
student1 = studnet(‘xiao ming’)
student2 =
静态方法
class cat(object):
@staticmethod
def call():
print(‘喵’)
cat.call()
私有属性私有方法
class women():
def init(self,name):
self.name = name
self.__age = 18
def __secert(self):
print(’%s 的年龄是%d’%(self.name,self.__age))
lily = women(‘Lily’)
print(Lily.name)
print(Lily.__age)
Lily.__secret()