python:实现日期加减操作

pip install python-dateutil
import datetime
from dateutil.relativedelta import relativedelta
sdate  = datetime.datetime.strptime('2019.01.05','%Y.%m.%d')
edate  = sdate + relativedelta(months=1)
print(edate)
2019.02.05

 

relativedelta(years=+2, months=+8, days=+16,hours=+20, minutes=+54, seconds=+47)

 

你可能感兴趣的:(python3基础,python)