问题描述
我的代码python代码在指定的时间后如何执行预定的动作?动作之间的时间不一致?当前显示的代码循环,但是我希望第一个动作启动,然后停止以便下一个动作在其时间启动。我正在构建一个自动通知系统,该系统应该在不同的非统一时间后发送警报。当前代码不带任何输出,当有时,它会不断循环。
#import win_sound
import time
import datetime
from datetime import date
import calendar
my_date = date.today()
dt = datetime.datetime.Now()
x = dt.strftime("%H:%M")
#first function
def assembly():
print("morning")
#second function
def mental_math():
print("afternoon")
#loop to ensure code is always checking for time
while True:
#checks if today's date and time matches with specified date and time
Today = calendar.day_name[my_date.weekday()]
if Today == 'Friday':
if x == "10:18":
assembly()
else:
time.sleep(1)
pass
if Today == 'Friday':
if x == "10:17":
mental_math()
else:
time.sleep(1)
pass
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)