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)
  • 相关阅读:
    Access小用之感
    PHP学习之路今日开启
    IBatis初体验2
    PHP之PDO介绍
    javascript key code 大全
    如何将虚拟机中的Linux系统与shell终端连接
    linux磁盘情况查询
    vi和vim编辑器的使用
    Linux磁盘分区,挂载
    (转)Android Dalvik虚拟机初识
  • 原文地址:https://www.cnblogs.com/diracy/p/13473211.html
Copyright © 2011-2022 走看看