源自python cookbook 记录下来,以免以后忘记了
- #!/usr/bin/python
- from dateutil import rrule
- import datetime
- def workdays(start, end, holidays=0, days_off=None):
- if days_off is None:
- days_off = 5, 6
- workdays = [x for x in range(7) if x not in days_off]
- days = rrule.rrule(rrule.DAILY, destart=start, until=end, byweekday=workdays)
- return days.count() - holidays
阅读(3104) | 评论(0) | 转发(0) |