更新时间:2022-03-13 01:14:34
Pygame 是为制作(图形)游戏而设计的,因此它仅在显示窗口时捕获按键操作.正如 Ignacio 在他的回答中所说,从命令行阅读和从另一个窗口阅读是非常不同的事情.
Pygame is designed for making (graphical) games, so it only captures key presses when there is a window displayed. As Ignacio said in his answer, reading from the command line and from another window are very different things.
如果你想创建一个命令行应用程序,试试curses:
If you want to create a command line application, try curses:
http://docs.python.org/library/curses.html
遗憾的是,它仅适用于 Linux 和 Mac OS X.
Unfortunately, it only works on Linux and Mac OS X.