How to process a key from a console application

I am using Python 2.6 and I want to know how I can use the console key. At the moment, I do not want to use Tkinter or another graphics library.

Below is my code.

history=[] while(1): try: cmd = self.get_cmd() history.append(cmd) # append user command # if i press UP key, just display history. # i'll you for statement to disaply history. print "%s" %history 
+4
source share
1 answer

For your purposes, you can look at the readline module designed for things like history processing, etc. This is the standard python library, so this may be what you need. And with another rlcompleter module , you can even handle autocomplete.

+2
source

Source: https://habr.com/ru/post/1447464/


All Articles