码迷,mamicode.com
首页 > 编程语言 > 详细

Python tab 补全

时间:2017-04-18 19:59:40      阅读:253      评论:0      收藏:0      [点我收藏+]

标签:python   tab   

1. 先准备一个tab.py的脚本

  shell> cat tab.py

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/python
# python tab 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)
  
del os, histfile, readline, rlcompleter

2. 查看Python默认的模块存放地址

1
2
3
4
5
6
7
[root@localhost ~]# python
Python 2.6.6 (r266:84292, Nov 22 201312:16:22)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help""copyright""credits" or "license" for more information.
>>> import sys
>>> sys.path
[‘‘, ‘/usr/lib64/python26.zip‘, ‘/usr/lib64/python2.6‘, ‘/usr/lib64/python2.6/plat-linux2‘, 

3. 拷贝该脚本到默认模块存放路径

1
cp tab.py  /usr/lib64/python2.6/

4. 现在可以用了

Python tab 补全

标签:python   tab   

原文地址:http://cstsncv.blog.51cto.com/4047083/1917139

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!