回答編集履歴

1

関連リンクを追加

2017/09/18 16:37

投稿

miyahan
miyahan

スコア3095

test CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
 
8
8
 
9
- そのなかで汎用性が高く使うのが簡単そうだったのが、[pnpnpn/timeout-decorator: Timeout decorator for Python](https://github.com/pnpnpn/timeout-decorator) というライブラリを使う方法で、input() 以外にも使えて便利そうでした。
9
+ そのなかで汎用性が高く使うのが簡単そうだったのが、[pnpnpn/timeout-decorator: Timeout decorator for Python](https://github.com/pnpnpn/timeout-decorator) というライブラリを使う方法で、input() 以外にも使えて便利そうでした。ただしシグナルを使っているため Windows では動かない可能性があります。
10
10
 
11
11
 
12
12
 
@@ -47,3 +47,15 @@
47
47
  print('時間切れ!')
48
48
 
49
49
  ```
50
+
51
+
52
+
53
+ そのほかの事例:
54
+
55
+
56
+
57
+ * シグナルを使った実装: [Keyboard input with timeout in Python - Stack Overflow](https://stackoverflow.com/questions/1335507/keyboard-input-with-timeout-in-python)
58
+
59
+ * シグナルを使った実装: [Simple key input with time out on python. タイムアウト付きキー入力。](https://gist.github.com/alfredplpl/ef9fb85e07e5dcb7363d)
60
+
61
+ * スレッドやタイマーを使った実装: [Python 3 Timed Input - Stack Overflow](https://stackoverflow.com/questions/15528939/python-3-timed-input) ←Windows向けのコードも紹介されています(かなり苦しい方法ですが)