标签:class elf static 静态属性 ssm app 内置函数 ice 对象
当对类的静态属性进行修改时(不需要借助于对象就行类静态属性的修改)
class Goods: discount = 0.5 def __init__(self,name,price): self.name = name self.__price = price @property def price(self): return self.__price * Goods.discount @classmethod def changeDiscount(cls,new_discount): cls.discount = new_discount apple = Goods(‘apple‘,10) Goods.changeDiscount(0.1) print(apple.price)
Python内置函数之classmetho staticmethod
标签:class elf static 静态属性 ssm app 内置函数 ice 对象
原文地址:https://www.cnblogs.com/wc89/p/10390447.html