Python 3定時輸入我想要做的是用輸入來問用戶一個問題。例如:print('some scenario')prompt = input("You have 10 seconds to choose the correct answer...\n")如果時間流逝,打印如下print('Sorry, times up.')如果能幫助我找到正確的方向,我將不勝感激。
3 回答
慕尼黑8549860
TA貢獻1818條經驗 獲得超11個贊
import timefrom threading import Threadanswer = Nonedef check():
time.sleep(2)
if answer != None:
return
print "Too Slow"Thread(target = check).start()answer = raw_input("Input something: ")添加回答
舉報
0/150
提交
取消
