python添加tab补全功能
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 rlcomplet
·
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
更多推荐
已为社区贡献9条内容
所有评论(0)