把这个文件导入到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程序的库路经。
转贴的,网上到处都是,确实不知道是抄的那里了。
来源:oschina
链接:https://my.oschina.net/u/854444/blog/500821