相关文章推荐
失眠的玉米  ·  使用Apache Spark 对 ...·  2 年前    · 
刚分手的肉夹馍  ·  About the GitHub ...·  3 年前    · 

源自python cookbook 记录下来,以免以后忘记了

点击( 此处 )折叠或打开

  1. # ! / usr / bin / python

  2. from dateutil import rrule
  3. import datetime

  4. def workdays ( start , end , holidays = 0 , days_off = None ) :
  5. if days_off is None :
  6. days_off = 5 , 6
  7. workdays = [ x for x in range ( 7 ) if x not in days_off ]
  8. days = rrule . rrule ( rrule . DAILY , destart = start , until = end , byweekday = workdays )
  9. return days . count ( ) - holidays