我在python中制作秒表类型程序,我想知道如何检测是否按下了一个键(例如p表示暂停,s表示停止),我不希望它像raw_input那样等待用户在继续执行之前的输入.任何人都知道如何在while循环中执行此操作?
另外,我想制作这个跨平台,但如果不可能,那么我的主要开发目标是linux
I have a simple python script, that has some functions that run in a loop (I'm taking sensor readings).
while True:
print "Doing a function"
Run Code Online (Sandbox Code Playgroud)
If the keyboard is pressed I'd like to print "key pressed".
What's the simplest way of doing this in Python? I've searched high and low. I've found out how to do it with pygame, but I'd rather do it without. If I do have to use pygame is it possible to not have a separate …