class Date: def init(self, year, month, day): self.year = year self.month = month self.day = day

def get_date(self):
    return f'{self.year}-{self.month}-{self.day}'

def get_year(self):
    return self.year

def get_month(self):
    return self.month

def set_date(self, year, month, day):
    self.year = year
    self.month = month
    self.day = day

def print_date(self):
    print(self.get_date())
Python 日期类实现:属性、方法及示例

原文地址: https://www.cveoy.top/t/topic/nww9 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录