##当天日期today = datetime.date.today()print(today)##获取当前月的第一天first = today.replace(day=1)print(first)##减一天,得到上个月的最后一天last_month = first - datetime.timedelta(days=1)print(last_month)print(last_month.strftime("%Y%m"))