Reprint: https://www.cnblogs.com/fireflow/p/4841413.html
The ReadLine module defines a series of functions used to read and write the history commands in the Python interpreter, and to provide auto-complete command functions. This module can be called directly through the Relcompleter module, and the settings in the module will affect the interaction hints in the interpreter, as well as the hints provided by the built-in functions raw_input () and input ().
#The ReadLine module defines the following methods:Readline.parse_and_bind (String):#parses and executes the command-line initialization file. Readline.get_line_buffer ():#returns the contents of the current command-line cache. Readline.insert_text (String):#inserts into the current line. Readline.read_init_file ([filename]):#parses a command-line initialization file. Readline.read_history_file ([filename]):#read History command file, default is ~/.historyReadline.write_history_file ([filename]):#Save History Command file, default to ~/.historyReadline.get_history_length ():#gets the preset number of historical command bars. A negative number means that the bar size is not restricted. Readline.set_history_length (length):#sets the number of command bars to be saved to the history command file, and Write_history_file () uses this number to modify the history command file. Readline.get_current_history_length ():#returns the number of bars in the history command in the current history file. Readline.get_history_item (Index):#Gets the history command specified by the index indexes. Readline.remove_history_item (POS):#deletes the history command at the specified location. Readline.replace_history_item (POS, line):#replaces the command at the specified location with the given command. Readline.redisplay ():#updates the display of the current screen in real time based on the command line cache. Readline.set_startup_hook ([function]):#Sets or removes the hook function, and if a function is specified, it is set to the hook function, \
If none is specified or set to None, all installed hook functions are removed and the hook function executes before the command line output prompt. Readline.set_pre_input_hook ([function]):#similar to the Set_startup_hook () method, but the hook function is executed before the command line begins to read the string after the prompt is entered. Readline.set_completer ([function]):#If a function is provided, it is used as an auto-complete command function, and if omitted or set to None, the previously set function is removed. \
The command automatically completes the function form functions (text,state), text is the string entered in the command line, and state is the selected complement command index. Readline.get_completer ():#returns the auto-complete command function. Readline.get_completion_type ():#returns the type of AutoComplete. Readline.get_begidx ():#gets the index of the first value of the Command Line tab auto-completion range. Readline.get_endidx ():#gets the index of the last value of the Command Line tab auto-completion range. Readline.set_completer_delims (String):#sets the delimiter between auto-complete commands. Readline.get_completer_delims ():#gets the separator character. Readline.set_completion_display_matches_hook ([function]):#Sets or removes the auto-complete display function. Readline.add_history (line):#Add the last input command to the history file.
Python-readline Module