一、创建自动补全脚本如下:
vi /tmp/python/tab.py
#!/usr/bin/python
# python tab 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
二、导入上面创建的模块
#python
>>>import sys
>>>sys.path.append(‘/tmp/python/‘)
>>>import tab
#之后便可利用TAB补全了
时间: 2024-12-21 10:42:49