1. 程式人生 > >Django 之 月份加減

Django 之 月份加減

第三方模組 :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