2024-09-26 18:12:19 发布
网友
例如,我希望如此
x = int(input("Please enter your guess :") If x = 1: Print ("correct")
尽管每次我需要按enter键,但我怎样才能使它在按键时显示出来。
我确实找到了getch(),尽管我无法让它工作。
在Windows中,您可以使用msvcrt。在其他系统上,这有点困难,看看这个配方:http://code.activestate.com/recipes/134892/
msvcrt
你可以这样使用它:
getch = _Getch() print 'Please enter your guess: ' x = getch() if (int(x) == 1): print 'correct' else: print 'wrong'
在Windows中,您可以使用
msvcrt
。在其他系统上,这有点困难,看看这个配方:http://code.activestate.com/recipes/134892/你可以这样使用它:
相关问题 更多 >
编程相关推荐