Python command line completion
As you know, when you enter a command in the command line interface, you can use the TAB key to fill in the command, which is easy to set up without wasting a long time on the input command. Recently started contacting Python and found that using the TAB key under the Python command line is not a complete command. Can we set the pattern to complete the command line? The answer is yes.
We can import modules under the Python command line
Import ReadLine, Rlcompleter; Readline.parse_and_bind ("Tab:complete")
With this setting, we can use the TAB key to complete the completion. But the downside to this approach is that you shut down the interface, and when you re-enter the Python interface, you have to re-enter the command, which is a hassle.
So, we can also write a configuration file that will permanently write this parameter
Create a file: ~/.pythonstartup.py
Vim ~/.pythonstartup.pyimport ReadLine, Rlcompleter; Readline.parse_and_bind ("Tab:complete")
Add an environment variable inside the ~/.BASHRC
Vim ~/.bashrcexport pythonstartup=~/.pythonstartup.py
Finally again source ~/.BASHRC
In this way, each time you start Python, you can automatically complete the command
This article is from the "xhk__" blog, please be sure to keep this source http://xhk777.blog.51cto.com/13405744/1980841
Python command line completion