我正在用python编写一个curses应用程序。你知道吗
def main(stdscr):
stuff(stdscr)
def printStuff(stdscr, string):
stdscr.clear()
stdscr.addstr(0, 0, string)
stdscr.refresh()
def stuff(stdscr):
printStuff(stdscr, 'foo')
time.sleep(3)
printStuff(stdscr, 'bar')
stdscr.getch()
wrapper(main)
当我运行代码时,大部分都是好的。 如果我在睡眠时按一个3秒间隔的按钮,getch会很高兴地将其作为输入,即使在调用getch之前按下了该按钮。为什么会这样,我怎样才能解决这个问题?你知道吗
输入是缓冲的,
getch()
处理输入缓冲区中的任何内容。可以用curses.flushinp清除缓冲区相关问题 更多 >
编程相关推荐