如果某一天x
是假日,则将days
添加到日x
,直到它不是假日。
def is_lastday_holiday(lastday):
while lastday in sorted(holidays.AT(years=2017)):
lastday + timedelta(days=1)
return lastday
这导致无限循环。任何提示?
答案 0 :(得分:3)
您错过了分配和更新lastday
。
def is_lastday_holiday(lastday):
while lastday in sorted(holidays.AT(years=2017)):
lastday = lastday + timedelta(days=1)
return lastday
或者,
lastday += timedelta(days=1)