python 多线程 无阻塞获取键盘按键

编程小白 python 多线程 无阻塞获取键盘按键


刚开始学,不喜勿喷,谢谢

import sys
import tty
import termios
import os
import threading


def readchar():
    fd = sys.stdin.fileno()
    old_settings = termios.tcgetattr(fd)
    try:
        tty.setraw(sys.stdin.fileno())
        ch = sys.stdin.read(1)
    finally:
        termios.tcsetattr(fd

你可能感兴趣的:(python 多线程 无阻塞获取键盘按键)