Python获取前一天的日期,前一个月的第一天,前一个月的最后一天
话不多说上代码
import datetime
from dateutil.relativedelta import relativedelta
curr_time2 = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
curr_time = datetime.datetime.now()
new_time_2 = (curr_time + relativedelta(days=-1)).strftime("%Y-%m-%d %H:%M:%S")
m = (curr_time + relativedelta(months=-1)).strftime("%Y-%m-%d %H:%M:%S")
first_day = datetime.date(datetime.date.today().year, datetime.date.today().month - 1, 1)
last_day = datetime.date(datetime.date.today().year, datetime.date.today().month, 1) - datetime.timedelta(1)
看到这你不关注+点赞+收藏吗,创作不易