반응형
파이썬에서 "키 누르기"(또는 메뉴 옵션 가져 오기)를 수행하려면 어떻게해야합니까?
표준 라이브러리를 사용하여이를 수행 할 수있는 휴대용 방법이 있습니까?
해결 방법
try:
# Win32
from msvcrt import getch
except ImportError:
# UNIX
def getch():
import sys, tty, termios
fd = sys.stdin.fileno()
old = termios.tcgetattr(fd)
try:
tty.setraw(fd)
return sys.stdin.read(1)
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old)
참조 페이지 https://stackoverflow.com/questions/1394956
반응형
'파이썬' 카테고리의 다른 글
파이썬 When to use Tornado, when to use Twisted / Cyclone / GEvent / other (0) | 2021.02.01 |
---|---|
파이썬 Extract day of year and Julian day from a string date (0) | 2021.02.01 |
파이썬 Python으로 SQL 구문 분석 (0) | 2021.02.01 |
파이썬 `bin (30)`이`0b11110` 대신`00011110`을 반환하도록하려면 어떻게해야합니까? (0) | 2021.02.01 |
파이썬 LF를 CRLF로 어떻게 변환합니까? (0) | 2021.01.31 |
댓글