막혔습니다. 그 날은 어딘가에서 int로 덮어 쓰여지고있는 것처럼 보입니다. 그러나 어디에서? 하루가 int가되는 곳은 어디입니까?date.day()가 TypeError를 반환합니다. '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
제발 추적 *을 포함하십시오. 오류가없는 곳에서 오류가 어디에 있는지를 추측하기는 어렵습니다. –