import datetime import calendar def get_next_month(): # 获取当前日期 now_time = datetime.datetime.now() # 获取当前时间的星期数和月数 week, days_num = calendar.monthrange(now_time.year, now_time.month) # 获取本月的最后一天 end_day_in_month = now_time.replace(day=days_num) # 获取下月的第一天 next_month = end_day_in_month + datetime.timedelta(days=1) # 返回下月的年月份 return next_month.strftime("%Y-%m")