Linux下Python模式下【Tab】自动补全
来源:互联网 发布:沃特沃德 知乎 编辑:程序博客网 时间:2024/06/06 14:20
在Python模式交互下,tab自动补全会提高代码效率,通过以下步骤可以很方便的实现自动补全。
1.获取操作目录
[root@liu site-packages]# pythonPython 2.6.6 (r266:84292, Nov 22 2013, 12:16:22) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2Type "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', '/usr/lib64/python2.6/lib-tk', '/usr/lib64/python2.6/lib-old', '/usr/lib64/python2.6/lib-dynload', '/usr/lib64/python2.6/site-packages', '/usr/lib64/python2.6/site-packages/gtk-2.0', '/usr/lib/python2.6/site-packages']>>>
可以看出,我的工作目录是/usr/lib/python2.6/site-packages/。
2.进入工作目录,编写tab.py补全文件
[root@liu site-packages]# cd /usr/lib/python2.6/site-packages/[root@liu site-packages]# vim tab.py
tab.py内容如下,建议粘贴的时候保证格式正确性
1 #!/usr/bin/python 2 # python tab file 3 import sys 4 import readline 5 import rlcompleter 6 import atexit 7 import os 8 # tab completion 9 readline.parse_and_bind('tab: complete') 10 # history file 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
3.添加环境变量,使其生效
[root@liu site-packages]# cd [root@liu ~]# vim .bashrc
在末尾添加一行
export PYTHONSTARTUP=/usr/lib/python2.6/site-packages/tab.py
4.重读.bashrc文件
source .bashrc
或者
. .bashrc
5.测试效果
[root@liu ~]# pythonPython 2.6.6 (r266:84292, Nov 22 2013, 12:16:22) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> import math>>> math.math.__class__( math.acos( math.fsum(math.__delattr__( math.acosh( math.hypot(math.__dict__ math.asin( math.isinf(math.__doc__ math.asinh( math.isnan(math.__file__ math.atan( math.ldexp(math.__format__( math.atan2( math.log(math.__getattribute__( math.atanh( math.log10(math.__hash__( math.ceil( math.log1p(math.__init__( math.copysign( math.modf(math.__name__ math.cos( math.pimath.__new__( math.cosh( math.pow(math.__package__ math.degrees( math.radians(math.__reduce__( math.e math.sin(math.__reduce_ex__( math.exp( math.sinh(math.__repr__( math.fabs( math.sqrt(math.__setattr__( math.factorial( math.tan(math.__sizeof__( math.floor( math.tanh(math.__str__( math.fmod( math.trunc(math.__subclasshook__( math.frexp( >>> math.
完成。我一开始一直报错,然后通过排查就是因为tab.py格式不正确。注意其格式。
0 0
- Linux下Python模式下【Tab】自动补全
- linux下配置python命令tab键自动补全
- 交互模式下python自动补全
- python linux上交互模式tab自动补全代码
- windows下python实现tab自动补全的方法
- Win10下Python命令tab自动补全
- python环境下使用tab自动补全命令
- linux下python自动补全命令
- python Linux Tab自动补全
- Mac下git tab自动补全
- Mac git 下 tab 自动补全
- 交互模式下PYTHON自动补全和VIM中PYTHON自动补全
- Emacs 设置 Python 编辑模式下的自动补全
- python <tab>自动补全
- Python TAB 自动补全
- python <tab>自动补全
- linux环境下tab 自动补全功能
- Linux设置python自动tab自动补全
- 第七周项目1—建立顺序环形队列算法库
- DNS 原理入门
- JQuery输入框中输入内容改变事件
- LINUX设备驱动模型之class
- Android中RecyclerView出现Bug:IndexOutOfBoundsException: Inconsistency detected. Invalid item position
- Linux下Python模式下【Tab】自动补全
- 3.npm
- 单链表反转(C++)
- Docker学习总结(16)——当当网Docker应用实践
- Fragment 通过构造函数传数据 出现崩溃Bug
- eclipse从数据库逆向生成Hibernate实体类
- 第七周-项目四 队列数组
- 个人总结
- C++(类-1)