所以我一直在玩一點點的時間表,我發現Schedule github有時間表,也非常好,易於使用。所以我迄今所做的是:Python - 格式/修剪,以便它給出正確的時間?
UserInput = input('To run Schedule script - Press y\nTo run directly - Press n\n')
if(UserInput == 'n'):
main()
elif(UserInput == 'y'):
TimeUser = input('What time to start script? Format - HH:MM ')
schedule.every().day.at(TimeUser).do(main)
wipe()
print('Schedule starts at: ' + TimeUser + ' - Waiting for time...')
while True:
schedule.run_pending()
time.sleep(1)
if(schedule.idle_seconds() == '5'):
print('Program starts in...:\n' + str(schedule.idle_seconds()) + '\n')
但是什麼即時得到了現在的問題是,我的輸出結果是
程序啓動中...: 30.08442
Program starts in...:
29.083967
Program starts in...:
28.083956
Program starts in...:
27.083923
基本上我想要做的是if(schedule.idle_seconds()): 5秒。所以當它離開5秒鐘時,它應該開始打印出來。然而,我得到的問題是,由於毫秒我想,它不會達到5秒。所以我想知道是否有一種方法可以修剪/剪切/格式化它,以便它在5秒鐘後開始打印?
編輯OUTPUTT:
--------------------------------------
Schedule starts at: 13:55 - Waiting for time...
--------------------------------------
Program starts in...:
4.748427
--------------------------------------
Wrong input - Try again
--------------------------------------
To run Schedule task - Press y
To run directly - Press n
我認爲,即時通訊越來越奇怪錯誤。然而,當我嘗試運行這個,它確實說程序開始於:....但後來告訴我,我的輸入是錯誤的..那多奇怪..我編輯我的線程,讓你知道輸出 – WeInThis
嗯...現在它的股價下跌至-0 ... ''' 計劃開始於...: 2.733921 計劃在開始...: 1.733449 計劃開始於...: 0.732948 計劃的開始...: -0.267551 -------------------------------------- 錯誤的輸入 - 再試一次 -------------------------------------- 要運行計劃任務 - 按y 要直接運行 - 按n ''' – WeInThis
我認爲不是有'break'我可以使用main()。對? – WeInThis