python自動補全tab配置
阿新 • • 發佈:2018-12-20
1,建立tab.py指令碼
#!/usr/bin/python # python tab complete
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
2,將tab.py放入python安裝目錄下
>>> import sys >>> sys.path ['', '/usr/lib/python26.zip', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/site-packages', '/usr/lib/python2.6/site-packages/gst-0.10', '/usr/lib/python2.6/site-packages/gtk-2.0', '/usr/lib/python2.6/site-packages/webkit-1.0'] >>>
python的模組放在了/usr/lib/python26/下面,將指令碼拷貝到該目錄下,在使用時匯入即可。
3, 使用時匯入tab
>>> import tab