计算两个日期之间的工作日并从列表中排除日期
Count weekdays between two dates and exclude dates from list
此代码计算两个日期之间的工作日。
from dateutil.rrule import *
number_weekdays = rrule(WEEKLY, byweekday=(SU,MO,TU,WE,TH),
dtstart=datetime.datetime(2021, 5, 1),
until=datetime.datetime(2021, 6, 30)).count()
我应该怎么做才能从列表中排除日期?
我知道 'exdate' ,但我不知道如何在此代码中使用它
import datetime
from dateutil.rrule import *
rules = rruleset()
# all days to count
rules.rrule(rrule(WEEKLY, byweekday=(SU,MO,TU,WE,TH,FR,SA),
dtstart=datetime.datetime(2021, 5, 1),
until=datetime.datetime(2021, 6, 30)))
# exlude days from list
rules.exrule(number_weekdays)
rules.count()
此代码计算两个日期之间的工作日。
from dateutil.rrule import *
number_weekdays = rrule(WEEKLY, byweekday=(SU,MO,TU,WE,TH),
dtstart=datetime.datetime(2021, 5, 1),
until=datetime.datetime(2021, 6, 30)).count()
我应该怎么做才能从列表中排除日期?
我知道 'exdate' ,但我不知道如何在此代码中使用它
import datetime
from dateutil.rrule import *
rules = rruleset()
# all days to count
rules.rrule(rrule(WEEKLY, byweekday=(SU,MO,TU,WE,TH,FR,SA),
dtstart=datetime.datetime(2021, 5, 1),
until=datetime.datetime(2021, 6, 30)))
# exlude days from list
rules.exrule(number_weekdays)
rules.count()