摘要:
类的继承:四大支柱(抽象、多态、继承、封装)之一,优点:代码重用 class Car(): def __init__(self, make, model, year): #初始化描述汽车的属性 self.make = make self.model = model self.year = year 阅读全文
摘要:
定义一个类描述数字时钟,要求:给定一个时间,例如15:50:00,则最终的效果为,如图: import time # 导入时间模块 class Clock(object): def __init__(self, h, m, s): # 时间初始化 self.hour = h self.minute 阅读全文