问题
因为股市在周末休市,所以如果当前为周五,加3天,为周六,加2天,为周日或其他,加一天。
代码
import re
import time
import datetime
year, month, day = time.strptime("20210615", "%Y%m%d")[:3]
day = datetime.date(year, month, day)
if day.weekday() == 4 :
next_day = day + datetime.timedelta(days=3)
elif day.weekday() == 5:
next_day = day + datetime.timedelta(days=2)
else:
next_day = day + datetime.timedelta(days=1)
print(next_day)
s = str(next_mondy)
print(s)
附录
Hbuilder
可以使用ctrl + alt + 上\下或者鼠标拖动,选中多行同时编辑