如何捕获使用python schedule包调度的函数的返回值
我已将我的函数安排在每天特定的时间运行 我向它传递一个参数,函数返回一个值,我需要在代码中使用该值进行进一步计算 我怎么抓住它 代码段:如何捕获使用python schedule包调度的函数的返回值,python,schedule,Python,Schedule,我已将我的函数安排在每天特定的时间运行 我向它传递一个参数,函数返回一个值,我需要在代码中使用该值进行进一步计算 我怎么抓住它 代码段: import schedule as sd import time def dothis(h): h-=1 print("Hour left : "+str(h)) return(h) h=24 d="14:00" sd.every().day.at(d).do(dothis,h) # how to catch the value
import schedule as sd
import time
def dothis(h):
h-=1
print("Hour left : "+str(h))
return(h)
h=24
d="14:00"
sd.every().day.at(d).do(dothis,h) # how to catch the value here?
while True:
sd.run_pending()
time.sleep(1)
只需将函数赋给一个变量,它就会引用该对象
只需将函数赋给一个变量,它就会引用该对象
import schedule as sd
import time
def dothis(h):
h-=1
print("Hour left : "+str(h))
return h
h=24
d="14:00"
sd.every().day.at(d).do(dothis,h)
a = dothis(h)
while True:
sd.run_pending()
return_value = a
time.sleep(1)