python_class
@property 把对象封装为属性,@classmethod 类对象
class School:
school_id = 123456
def __init__(self, name, addr, type):
self.name = name
self.addr = addr
self.type = type
@property
def instance_info(self):
print("学校名称:%s" % self.name)
print("学校地址:%s" % self.addr)
print("学校类型:%s" % self.type)
@classmethod
def school_info(cls):
print("学校标识号:%s"%cls.school_id )
my_sch = School("利辛中学", "锦绣路", "公办")
my_sch.instance_info
School.school_info()