1
我正在處理的程序需要暫停並詢問用戶輸入,如果沒有,請繼續使用該程序。我認爲它看起來像這樣:請求用戶輸入python中的有限時間
import time
...[code to run before break]...
if input in time.sleep(5):
[break out of normal code]
else:
[return to normal code]
[code to run after break]...
有什麼想法?
編輯:沒有想到這個,當我問,但我運行Windows(8.1)。
谷歌是你的朋友編碼... http://stackoverflow.com/questions/1335507/keyboard-input-with-timeout-in-python [1]:HTTP:// stackoverflow.com/questions/1335507/keyboard-input-with-timeout-in-python – FlyingGuy 2015-02-10 04:10:33
沒有想到使用單詞「超時」。這就解釋了爲什麼我無法在google上獲得結果。 – unknown 2015-02-10 04:20:52