阻止python中的键盘输入 [英] Block keyboard input in python
问题描述
在Python中,有没有一种方法可以防止用户通过键盘输入任何东西,以使终端输出不会因不必要的输入而变得混乱?
In Python, is there a way to prevent the user from entering anything via keyboard, so that terminal output does not get cluttered by unneeded input?
在我的情况下,应该让用户按住一个键来注册特定的键盘-因此,不需要实际的输入(如input()
中所示),而只会使输出和菜单混乱.
In my case, the user is supposed to press and hold a key to register a specific keyboard - so, the actual input (as in input()
) is not needed, but only clutters the output and menu.
推荐答案
听起来您希望终端内容根据用户输入重绘吗?
It sounds like you want the terminal contents to redraw themselves on user input?
https://docs.python.org/3/howto/curses.html 或 https://docs.python.org/2.7/howto/curses .html 取决于python版本.
https://docs.python.org/3/howto/curses.html or https://docs.python.org/2.7/howto/curses.html depending on python version.
另请参见此问题使用python进行动态终端打印
这篇关于阻止python中的键盘输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!