import datetime
from dateutil.relativedelta import relativedelta
# Get current date
today = datetime.date.today()
# Get first day of previous month
first_day = today.replace(day=1) - relativedelta(months=1)
# Get last day of previous month
last_day = today.replace(day=1) - datetime.timedelta(days=1)
# Format dates
start = first_day.strftime('%d-%b-%Y')
end = last_day.strftime('%d-%b-%Y')
# Print dates
print("Start date:", start)
print("End date:", end)
3条答案
按热度按时间bqujaahr1#
根据需要格式化。
vcudknz32#
smtd7mpg3#
第一次约会永远是第一次
进口是
你可以在一月份加上一个条件所以要在十二月份。如果有任何问题,只是添加评论,我也会添加。