python命令行tab实例小妙招
用习惯了tab实例,在python command line下面不能使用tab补全感觉很是不爽有没有,在网上找了一下tab实例的方法,基本上都大同小异。参考:http://askubuntu.com/questions/25605/how-can-i-get-tab-completion-in-the-interactive-python-interpreter
这个方法亲测有效,但是涉及到改环境变量什么的感觉有点麻烦,直接弄成模块导入更方便
1,找到python的lib路径
1
# cd /usr/lib/python2.7/site-packages
2,vim tab.py 照抄链接中的代码就好了:
1
2
3
4
5
6
7
8
#!/usr/bin/env python
try:
import readline
except ImportError:
print("Module readline not available.")
else:
import rlcompleter
readline.parse_and_bind("tab: complete")
看效果:
1
2
3
4
5
6
7
8
9
10
$ python
Python 2.7.5 (default, Nov 20 2015, 02:00:19)
on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tab
>>> s='abc'
>>> s
s setattr( sorted( str( super(
set( slice( staticmethod(sum(
>>>
任何用户都可以直接通过import tab来使用噢!
页:
[1]