Python之Tab键自动补全

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

 1 # python start file
 2 import sys 
 3 import readline
 4 import rlcompleter
 5 import atexit
 6 import os
 7 
 8 # tab completion
 9 readline.parse_and_bind('tab: complete')
10 
11 # history file
12 histfile = os.path.join(os.environ['HOME'], '.pythonhistory')
13 try:
14         readline.read_history_file(histfile)
15 except IOError:
16         pass
17 atexit.register(readline.write_history_file, histfile)

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


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

原文地址:https://www.cnblogs.com/fallenmoon/p/6995645.html