python 时间处理之月份加减

2023-01-31 05:01:53 python 时间 加减

第三方模块 :python-dateutil

安装方式:pip install Python-dateutil

实例代码:

import datetime
from dateutil.relativedelta import relativedelta

datetime_now = datetime.datetime.now()
datetime_three_month_aGo = datetime_now - relativedelta(months=3)
print datetime_three_month_ago

相关文章