zoukankan      html  css  js  c++  java
  • classmethod练习

    # class Cou:
    # __discount=0.8
    # def __init__(self):
    # self.price=5
    # self.price=self.price*self.__discount
    # @property
    # def nowdiscount(self):
    # print(Cou.__discount)
    # @nowdiscount.setter
    # def nowdiscount(self,newdiscount):
    # Cou.__discount=newdiscount
    # appele=Cou()
    # print(appele.price)
    # appele.nowdiscount
    # appele.nowdiscount=0.5
    # appele=Cou()
    # appele.nowdiscount
    # print(appele.price)




    # class A:
    # __discount=0.8
    # def __init__(self,price):
    # self.price=A.__discount*price
    # def changweight(self,newdiscount):
    # A.__discount=newdiscount
    # a=A(10)
    # print(a.price)
    # a.changweight(0.6)
    # a=A(10)
    # print(a.price)

    # #classmethod
    # class A:
    # __discount=0.8
    # def __init__(self,price):
    # self.price=A.__discount*price
    # @classmethod
    # def changediscount(cls,newdiscount):
    # cls.__discount=newdiscount
    # a=A(10)
    # print(a.price)
    # a.changediscount(0.6)
    # # A.changediscount(0.6)
    # a=A(10)
    # print(a.price)
    # import time
    # class Date:
    # def __init__(self,year,month,day):
    # self.year = year
    # self.month = month
    # self.day = day
    # @classmethod
    # def today(cls):
    # date=cls(time.localtime().tm_year,time.localtime().tm_mon,time.localtime().tm_mday)
    # return date
    # print(Date.today().year)
    # print(Date.today().month)
    # print(Date.today().day)
  • 相关阅读:
    Kibana
    Filebeat使用
    leetcode刷题笔记七十三题 矩阵置零
    leetcode刷题笔记七十二题 编辑距离
    leetcode刷题笔记七十一题 简化路径
    leetcode刷题笔记七十题 爬楼梯
    leetcode刷题笔记六十九题 X的平方根
    python 冒泡算法
    hive 函数
    Task07:类、对象与魔法方法(3天)
  • 原文地址:https://www.cnblogs.com/diracy/p/13473211.html
Copyright © 2011-2022 走看看