Python之Tab键自动补全

时间:2023-12-24 09:28:13

首先备份一下Tab键自动补全代码:

 # python start 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)

然后拷贝到Python系统目录下 sudo cp tab.py /usr/lib/python2.7/dist-packages/ ,这样就不用每次进入都还得导入啦


才发现,只有Python2.7以及Python3才有 /usr/lib/python2./dist-packages/ 这个目录,Python3.5没有,至于该放哪,我也不知道