python 交互界面tab补全
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 交互界面tab补全相关的知识,希望对你有一定的参考价值。
创建一个tab.py文件
代码:
#!/usr/bin/env python
import readline
import rlcompleter
import atexit
import os
# tab completion
readline.parse_and_bind(‘tab:complete‘)
#history file
historyfile = os.path.join(os.environ[‘HOME‘],‘.tab‘)
try:
readline.read_history_file(historyfile)
except:
pass
atexit.register(readline.write_history_file,historyfile)
del os,historyfile,readline,rlcompleter
>>> import sys
>>> sys.path
[‘‘, ‘/usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg‘, ‘/usr/lib64/python27.zip‘, ‘/usr/lib64/python2.7‘, ‘/usr/lib64/python2.7/plat-linux2‘, ‘/usr/lib64/python2.7/lib-tk‘, ‘/usr/lib64/python2.7/lib-old‘, ‘/usr/lib64/python2.7/lib-dynload‘, ‘/usr/lib64/python2.7/site-packages‘, ‘/usr/lib64/python2.7/site-packages/gtk-2.0‘, ‘/usr/lib/python2.7/site-packages‘]
将tab.py复制到 /usr/lib64/python2.7/site-packages 下
>>> import tab
>>> os.
就可以补全了
以上是关于python 交互界面tab补全的主要内容,如果未能解决你的问题,请参考以下文章