python获取当前月第一天和最后一天日期

python获取当前月第一天和最后一天

#!/usr/bin/env python
# encoding: utf-8
from datetime import datetime
import calendar

cur_month_start_day = "{}-01".format(datetime.now().strftime("%Y-%m"))
year, month = int(datetime.now().strftime('%Y-%m').split("-")[0]), int(
    datetime.now().strftime('%Y-%m').split("-")[1])
cur_month_end_day = "{}-{}-{}".format(year, month, calendar.monthrange(year, month)[1])

你可能感兴趣的:(Python,python)