建立.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键进行补全

原文来自:http://www.ywnds.com/?p=3051

本文地址:https://www.linuxprobe.com/python-auto-tab.html编辑:何云艳,审核员:逄增宝

Linux命令大全:https://www.linuxcool.com/