将日期时间.工作日( ) 更改为"MON"



我想让today变量是一周中x,y坐标的任何一天。使用datetime。weekday返回一个0,我不能把它赋值给坐标。我可以用7个if语句,但这似乎过多了。有没有更好的办法?

MON = (340, 431)
TUE = (529, 432)
WED = (721, 436)
THUR = (912, 436)
FRI = (1107, 435)
SAT = (1293, 436)
SUN = (1484, 434)
dow = dt.today().weekday() #get day of week
if dow == 0:
today = MON
if dow == 1:
today = TUE
pyautogui.click(today) #if today is monday the x,y coordinates of (340, 431) will be here
time.sleep(1)

创建一个包含坐标的数组,并使用down作为索引:

coords = [(340, 431),(529, 432),(721, 436),(912, 436),(1107, 435),(1293, 436),(1484, 434)]
dow = dt.today().weekday()
today = coords[dow] # note that the first day of the week may not be monday
pyautogui.click(today)

相关内容

最新更新