python-2.7-windows.msi下载
http://download.csdn.net/download/gsls200808/9336901
用python-2.7-windows.msi安装的python大多是没有tab补全功能的
首先下载编译好的Readline
http://pan.baidu.com/s/1i5r5RST
将以下四个文件复制到C:\Python27\Lib\site-packages下
Readline-1.7-py2.7.egg-info
readline.py
readline.pyc
_rlsetup.pyd
C:\Python27\Lib 添加python自动补全功能tab.py
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['HOMEPATH'], '.pythonhistory')
try:
readline.read_history_file(histfile)
except IOError:
pass
atexit.register(readline.write_history_file, histfile)
del os, histfile, readline, rlcompleter
注:win 下写成 HOMEPATH Linux 下HOME 否则会报错
import tab
Traceback (most recent call last):
File “”, line 1, in
File “C:\Python27\lib\tab.py”, line 10, in
histfile = os.path.join(os.environ[‘HOME’], ‘.pythonhistory’)
File “C:\Python27\lib\os.py”, line 425, in getitem
return self.data[key.upper()]
KeyError: ‘HOME’
3.测试
import os
import sys
sys.