python 诅咒无法识别箭头键

时间:2021-04-24 04:43:23

标签: python python-3.x curses

我有这个简单的程序。程序中也没有错误,当我按 q 程序退出时

import curses

def main(stdscr):
    while 1:
        Key = stdscr.getch()
        if Key == curses.KEY_UP:
            stdscr.addstr(0,0,'u pressed up key ')
            stdscr.refresh()
        elif Key == curses.KEY_DOWN:
            stdscr.addstr(0,0,'u pressed down key')
            stdscr.refresh()
        elif Key == curses.KEY_LEFT:
            stdscr.addstr(0,0,'u pressed left key')
            stdscr.refresh()
        elif Key == curses.KEY_RIGHT:
            stdscr.addstr(0,0,'u pressed right key')
            stdscr.refresh()
        elif Key == ord('q'):
            break
curses.wrapper(main)

0 个答案:

没有答案