类对象可以调用
class Flower: #类属性 nums = 10 #实例方法 def __init__(self,breed,color): #实例属性 self.breed = breed self.color = color self.nums_operate() #实例方法 def info(self): print('品种:%s,颜色:%s'%(self.breed,self.color)) #类方法 @classmethod def nums_operate(cls): cls.nums -= 1 #静态方法 @staticmethod def residue(): if Flower.nums <= 0: print('今日鲜花已卖完!!') else: print('今日鲜花还剩:%s'%(Flower.nums)) f = Flower('百合','白色') print(f.nums) print(Flower.nums) f.nums_operate() Flower.nums_operate() f.residue() Flower.residue() f.info() Flower.info(f)