您的位置:首页 > 运维架构 > Linux

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

2017-06-19 11:54 786 查看
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键自动补全功能。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: