您的位置:首页 > 编程语言 > Python开发

python添加tab补全功能

2017-10-11 22:30 507 查看
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.py

import sys
import readline
import rlcompleter
import atexit
import os

reload(sys)
sys.setdefaultencoding('utf-8')

# tab completion
readline.parse_and_bind('tab: complete')
# history file
# windows
histfile = os.path.join(os.environ['HOMEPATH'], '.pythonhistory')
# linux
# 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


2.安装第三方库

pip install pyreadline


3.存放位置

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


4.测试环境

window


5.使用方法

使用时,脚本需要导入
import tab
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: