import datetime print(datetime.date.today().strftime("%d/%m/%Y")) mytime = datetime.date(1992,12,20) #创建一个日期对象 print(mytime.strftime("%Y-%m-%d")) #将日期格式化 mynextdat = mytime + datetime.timedelta(days=2) # timedelta日期算术运算 print(mynextdat.strftime("%Y-%m-%d")) myfirstdate = mytime.replace(year=mytime.year+1) #日期替换 print(myfirstdate.strftime("%Y-%m-%d"))
python datetime模块
最新推荐文章于 2024-03-27 11:23:57 发布