前言
把这个文件导入到python自带的IDE下,再按TAB键就会有提示,需要readline库,在新的版本中,可能名字是gnureadline库,
需要安装 :
pip install gnureadline
或
pip install readline
也可以在pipy.python.org下载源码进行 /opt/python35/bin/python3 setup.py install 安装
但可能提示:依赖 ncurses ncurses-devel ,readline readline-devel
可以 yum install ncurses ncurses-devel readline readline-devel
cat tab.py
#!/opt/python35/bin/python3
# python startup file
import sys
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
现在,只要导入import tab按tab就可以实现提示和补全了,
其实可以把该文件放到python程序的库路经。