我的排班日期
import datetime cur_date = datetime.datetime.today()#已当日日期2021-02-28为始(白班) # print(cur_date) day_work_list = [] #白班列表 night_work_list = [] #晚班列表 night_result = [] for i in range(0,1000,4): timedel = datetime.timedelta(days=i) #差值 # print(timedel) night_result.append(cur_date+timedel) # print(val) result = str(cur_date + timedel) day_work_list.append(result.split()[0])timedel_night = datetime.timedelta(days=1)
for x in night_result:
y=str(x+timedel_night).split()[0] #用白班日期+1等于晚班日期
night_work_list.append(y)value=input("按yy-mm-dd格式输入日期:")
if value in day_work_list:
print("上白班")
elif value in night_work_list:
print("上晚班")
else:
print("休息日")
qingming = ['2021-04-03','2021-04-04','2021-04-05']
laodongjie = ['2021-05-01','2021-05-02','2021-05-03','2021-05-04','2021-05-05']
duanwujie = ['2021-06-12','2021-06-13','2021-06-14']
zhongqiujie = ['2021-09-19','2021-09-20','2021-09-21']
guoqingjie = ['2021-10-01','2021-10-02','2021-10-03','2021-10-04','2021-10-05','2021-10-06','2021-10-07']
yuandanjie = ['2022-01-01','2022-01-02','2022-01-03']
chunjie = ['2022-01-31','2022-02-01','2022-02-02','2022-02-03','2022-02-04','2022-02-05','2022-02-06']dates = [qingming,laodongjie,duanwujie,zhongqiujie,guoqingjie,yuandanjie,chunjie]
for s in dates:
for ss in s[:]:
# print(ss)
if ss in day_work_list:
print('{},白班'.format(ss))
elif ss in night_work_list:
print('{},晚班'.format(ss))