class DataTest(object):
day = 0
month = 0
year = 0
def __init__(self, year=0, month=0, day=0):
self.day = day
self.month = month
self.year = year
def out_date(self):
print("year :", self.year)
print("month :", self.month)
print("day :", self.day)
@classmethod
def get_data(cls, string_date):
"""处理'2018-8-18'字符格式"""
year, month, day = map(int, string_date.split('-'))
return cls(year, month, day)