454luikty 发表于 2017-8-21 09:59:42

设置python中TAB键自动补全方法

一、创建自动补全脚本如下:
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补全了

页: [1]
查看完整版本: 设置python中TAB键自动补全方法