1

時間制限、カウントダウンを設定する方法を探しています。この関数を使用して、ユーザーが while ループを実行できる時間を制御します。これがどのように実行されているかの例です。

def run(strings, timeout=30):
    while timeout > 0:
        input = raw_input("prompts that will continue prompting as long as not timed out")
        if input != strings:
            #do something here, maybe be able to deduct off timer. 
        else:
            score += 1 
            print "%d /r" % timeout #print timeout
    return score 

私の例はあまりきれいではないかもしれませんが、それは一般的な考え方です。はtimeoutループを制御します。

timerこれはライブラリに対して実行できますか? 関数の実行中 (ユーザーにプロンプ​​トを表示) に時間を処理するために別のスレッドが必要ですか?

4

0 に答える 0