Python高级编程笔记(一)-- Linux下python命令行tab键自动补全功能设置

step 1: 用户主目录下创建并编辑文件.pythonstartup,文件内容如下:

#python startup file
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

step 2: 链接至环境变量,在用户主目录下的.bashrc文件中增加:

export PYTHONSTARTUP=".pythonstartup"


完成上述配置,即可实现python命令行tab键自动补全功能。

你可能感兴趣的:(Python)