第十一天:时间与日期
一、datetime 1、date 2、time import datetime datetime.MAXYEAR datetime.MINYEAR today = datetime.date.today() today today.year today.month today.day today.weekday() today.isoweekday() 9999 1 datetime.date(2019, 9, 7) 2019 9 7 5 6 3、datetime year month day birthdate = datetime.date(2010, 3, 12) birthdate.year birthdate.day t = datetime.time(15, 46, 32) t.hour t.minute t.second 2010 12 15 46 32 import datetime now = datetime.datetime.now() now now.year now.second now.microsecond #微秒 datetime.datetime(2019, 9, 7, 20, 14, 45, 543196) 2019 7 45 543196 4、格式转换 字符串到日期时间 datetime.datetime.strptime(‘txt’, ‘