win环境下python tab键补全

1,首先打开cmd窗口执行以下命令安装readline模块

python -m pip install pyreadline

 2,编写 tab.py 

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

放到Python安装目录

比如我的python安装在C:\Python3 目录

放到同级目录C:\Python3\tab.py

3,测试

 

posted @ 2017-07-30 17:44  别动我的网盘  阅读(403)  评论(0编辑  收藏  举报