建立.pythonstartup文件
$ cat .pythonstartup
# cat ~/.pythonstartup
# python startup file
#!/usr/bin/env python
import sys
import readline
import rlcompleter
import atexit
import os
# tab completion
readline.parse_and_bind('tab: complete')
# history file histfile = os.path.join(os.environ['HOME'], '.pythonhistory') try: readline.read_history_file(histfile) except IOError: pass atexit.register(readline.write_history_file, histfile) del os, histfile, readline, rlcompleter
定义变量到~/.bash_profile
$ echo 'export PYTHONSTARTUP=~/.pythonstartup' >> ~/.bash_profile
最后重新登陆shell,输入python命令进入交互模式,就可以用Tab键进行补全

Tel_1878886----