zoukankan      html  css  js  c++  java
  • python学习,day7 属性方法

    class Flight(object):
        def __init__(self,name):
            self.flight_name = name
    
    
        def checking_status(self):
            print("checking flight %s status " % self.flight_name)
            return  0
    
        @property  #把一个方法变成静态属性,可以对原值进行调用,修改,而又不修改方法。
        def flight_status(self):
            status = self.checking_status()
            if status == 0 :
                print("flight got canceled...")
            elif status == 1 :
                print("flight is arrived...")
            elif status == 2:
                print("flight has departured already...")
            else:
                print("cannot confirm the flight status...,please check later")
        @flight_status.setter
        def flight_status(self,status):
            print("flight %s has changed status to %s" %(self.flight_name,status))
    f = Flight("CA980")
    f.flight_status
    f.flight_status = 2
    

      

  • 相关阅读:
    MySQL-percona安装
    Oracle-19C PSU升级
    Oracle-内存管理机制
    学习进度第十二周
    十天冲刺10
    单词统计续
    十天冲刺9
    学习进度第十一周
    十天冲刺8
    十天冲刺7
  • 原文地址:https://www.cnblogs.com/bbgoal/p/12894775.html
Copyright © 2011-2022 走看看