没事儿写个脚本工作日以及周末的统计 可输出相对应的日期号数.

#!/usr/bin/python2

#auth:codewalker #mail:001@codewalker.me
#date:2013-12-15

import datetime
from calendar import monthrange

def get_year():
return str(datetime.date.today())[:4]

def get_month():
return str(datetime.date.today())[5:7]

def get_day():
return str(datetime.date.today())[-2:]

def get_weekenddays_and_businessdays(year, month):
i = 1
weekenddays = []
businessdays = []
already_work_days = []
count_days = monthrange(year, month)

if (year, month) == (int(get\_year()), int(get\_month())):
    currentday = int(get_day())
else:
    currentday = count_days\[1\]

while i <= count_days\[1\]:
    day\_of\_week = int(datetime.datetime(year, month,i).strftime("%w"))
    if day\_of\_week not in (0,6):
        businessdays.append(i)
        if i <= currentday:
            already\_work\_days.append(i)
    else:
        weekenddays.append(i)
    i += 1
return (businessdays, weekenddays, already\_work\_days)

def main():

y = int(get_year())
m = int(get_month())

d = get\_weekenddays\_and_businessdays(y, m)
print "%s - %s" % (y, m)


print "businessdays: \[%s\], weekenddays: \[%s\]." % \
        (len(d\[0\]),len(d\[1\]))

print "You have ALREAD work \[%d\] days. Remaining \[%s\] days to work..." % \
        (len(d\[2\]), len(d\[0\])-len(d\[2\]))

print d

if __name__ == “__main__“:
main()

#OUTPUT
#2013 - 12:
#businessdays: [22], weekenddays: [9].
#You have ALREAD work [10] days. Remaining [12] days to work…
([2, 3, 4, 5, 6, 9, 10, 11, 12, 13, 16, 17, 18, 19, 20, 23, 24, 25, 26, 27, 30, 31], [1, 7, 8, 14, 15, 21, 22, 28, 29], [2, 3, 4, 5, 6, 9, 10, 11, 12, 13])