win python2.7 引入tab

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.

阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/fxyfdf/article/details/59530111
个人分类: python
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭