1 #判断是否为工作日,工作日返回1,非工作日返回0
2 def workDay():
3 workTime=['09:00:00','18:00:00']
4 dayOfWeek = datetime.datetime.now().weekday()
5 #dayOfWeek = datetime.today().weekday()
6 beginWork=datetime.datetime.now().strftime("%Y-%m-%d")+' '+workTime[0]
7 endWork=datetime.datetime.now().strftime("%Y-%m-%d")+' '+workTime[1]
8 beginWorkSeconds=time.time()-time.mktime(time.strptime(beginWork, '%Y-%m-%d %H:%M:%S'))
9 endWorkSeconds=time.time()-time.mktime(time.strptime(endWork, '%Y-%m-%d %H:%M:%S'))
10 if (int(dayOfWeek) in range(5)) and int(beginWorkSeconds)>0 and int(endWorkSeconds)<0:
11 return 1
12 else:
13 return 0