Python By default can be tab completion command line, in interactive mode, as long as you write a small tab.py module, the implementation code is as follows;
#!/bin/env python # -*- coding: utf-8 -*-# python startup file import sysimport readlineimport rlcompleterimport atexitimport osimport Platform# tab completion readline.parse_and_bind (' Tab: complete ') ## this for adding historical commands to the file, In the respective home directory, if you do not need to log the logs can be deleted If platform.system () == ' Windows ': # history file ,os.environ get the user's home directory, this is WIN10, Win7 system may need to change (see Os.environ key yourself) histfile = os.path.join (os.environ[' userprofile '], '. Pythonhistory ') else: # history file ,os.environ gets the user's home directory histfile = os.path.join ( os.environ[' HOME '], '. Pythonhistory ') ## end for history## #try: Readline.read_history_file (histfile) Except ioerror: passatexit.register ( Readline.write_history_file, histfile) dEl os, histfile, readline, rlcompleter
Copy the above code to save in a py file (your own name, and so on you need to import this module interactively), into your own PY environment in the search path can be
Start Python interaction
Import xxx
Then you import any one of the modules to test
How do you automatically import this module in Python when you start the PYTHONSTARTUP
environment variable to add this module to this environment variable
If it is a Windows system, define it in your own user variable(我的电脑==>属性==>高级==>环境变量==>用户变量)
PYTHONSTARTUP
The corresponding value is the path of the module you just saved.
If you are Linux, the path to the export module in your own user-variable environment ( /root/.bash_profile
or global variable/etc/export export PYTHONSTARTUP=/xxx/xx/xx.py
)
Overload environment variables (re-login) to test
Command tab completion in Python interactive mode