The OS is a Redhat-clone Linux distribution, I use python-2.x.
General code structure:
while True:
os.system("clear")
time.sleep(1)
I want to allow the user to control the program by pressing various keys. For example, "press S to shut down remote devices correctly, K to kill, R to reboot." All these actions should take place inside a large cycle - the comment “maybe do something or just watch” in my pseudo-code. If no key is pressed, the program should simply continue the cycle.
I'm not sure how to read from the keyboard in the context of the True: time.sleep (1) loop.
source
share