我被困住了。看来那一天正在某处被覆盖为 int 。但是哪里?day 在哪里变成 int?
from datetime import *
start_date = date(1901, 1, 1)
end_date = date(2000, 12, 31)
sundays_on_1st = 0
def daterange(start_date, end_date):
for n in range(int ((end_date - start_date).days)):
yield start_date + timedelta(n)
for single_date in daterange(start_date, end_date):
# type(single_date) => <type 'datetime.date'>
# type(date.day()) => TypeError: 'getset_descriptor' object is not callable
# type(single_date.day()) => TypeError: 'int' object is not callable
# ಠ_ಠ
if single_date.day() == 1 and single_date.weekday() == 6:
sundays_on_1st += 1
print sundays_on_1st