Python中的调度库和多定义函数
我想结合这两种代码:Python中的调度库和多定义函数,python,schedule,Python,Schedule,我想结合这两种代码: 导入计划 导入时间 祝你好运 打印(“考试好运”) 计划每天在(00:00)做(祝你好运) 尽管如此: schedule.run_pending() 时间。睡眠(1) 及 def myCommand(): 命令=输入('输入:') 返回命令 def助理(命令): 如果命令==“1”: 打印('是一个') 其他: 打印('不是一个') 尽管如此: 助理(myCommand()) 我在一半的实验中都出现了错误,而在另一半实验中,第一个代码根本不起作用。不清楚如何将这两个列表
导入计划
导入时间
祝你好运
打印(“考试好运”)
计划每天在(00:00)做(祝你好运)
尽管如此:
schedule.run_pending()
时间。睡眠(1)
及
def myCommand():
命令=输入('输入:')
返回命令
def助理(命令):
如果命令==“1”:
打印('是一个')
其他:
打印('不是一个')
尽管如此:
助理(myCommand())
我在一半的实验中都出现了错误,而在另一半实验中,第一个代码根本不起作用。不清楚如何将这两个列表组合起来。最简单的方法是在同一个循环中执行两个函数,但是此解决方案可能无法解决您的问题
import schedule
def good_luck():
print("Good Luck for Test")
def myCommand():
command = input("input: ")
return command
def assistant(command):
if command == "1":
print("is it one")
else:
print("is not one")
if __name__ == "__main__":
schedule.every().day.at("00:00").do(good_luck)
while True:
assistant(myCommand())
schedule.run_pending()
然后您可以得到以下输出
input: 1
is it one
input: 2
is not one
Good Luck for Test
请通过编辑您的问题以添加其他信息来记录您的预期结果。如前所述,考虑到“组合”两个代码示例的方法很多,很难确定您想要实现什么。