>>> from datetime import datetime >>> import calendar >>> now = datetime.strptime('2014-11-1', '%Y-%m-%d') datetime.datetime(2014, 11, 1, 0, 0) >>> #任意の月の日曜日の日にちをリストで取得する >>> [x[calendar.SUNDAY] for x in calendar.monthcalendar(now.year, now.month)] [2, 9, 16, 23, 30] >>> # ひと月に4回しかない曜日の場合、リストの先頭値が0になる >>> [x[calendar.MONDAY] for x in calendar.monthcalendar(now.year, now.month)] [0, 3, 10, 17, 24]
