python判断今天是否是本月的第一天

from datetime import datetime as dtime
import datetime


def firstDayOfMonth(dt):
   return (dt + datetime.timedelta(days= -dt.day + 1)).replace(hour=0, minute=0, second=0, microsecond=0)

print firstDayOfMonth(dtime.today()).day == dtime.today().day

你可能感兴趣的:(python 第一天)