完整代码
import datetime
(datetime.date.today().replace(day= 1) - datetime.timedelta(days= 1)).strftime("%Y-%m ")
获取本月第一天
byyc = datetime.date.today().replace(day= 1)
获取上月最后一天
syym = byyc - datetime.timedelta(days= 1)
获取上月月份
sy = syym.strftime("%Y-%m ")
标签:syym,timedelta,第一天,python,byyc,datetime,获取,today
From: https://blog.51cto.com/u_16055028/6400892