RosettaCodeData/Task/Keyboard-input-Flush-the-keyboard-buffer/Python/keyboard-input-flush-the-keyboard-buffer.py
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

8 lines
213 B
Python

def flush_input():
try:
import msvcrt
while msvcrt.kbhit():
msvcrt.getch()
except ImportError:
import sys, termios
termios.tcflush(sys.stdin, termios.TCIOFLUSH)