python添加tab补全功能

来源:互联网 发布:nginx 访问权限 编辑:程序博客网 时间:2024/05/10 01:51

1.code

#!/usr/bin/env/python#_*_coding:utf-8_*_#Data:17-10-08#Auther:苏莫#Link:http://blog.csdn.net/lingluofengzang#PythonVersion:python2.7#filename:tab.pyimport sysimport readlineimport rlcompleterimport atexitimport osreload(sys)sys.setdefaultencoding('utf-8')# tab completionreadline.parse_and_bind('tab: complete')# history file# windowshistfile = os.path.join(os.environ['HOMEPATH'], '.pythonhistory')   # linux# histfile = os.path.join(os.environ['HOME'], '.pythonhistory')try:    readline.read_history_file(histfile)except IOError:    passatexit.register(readline.write_history_file, histfile)del os, histfile, readline, rlcompleter 

2.安装第三方库

pip install pyreadline

3.存放位置

python安装文档位置下的Lib文件夹

4.测试环境

window

5.使用方法

使用时,脚本需要导入import tab