python tab complete

一、查询python安装路径,一般默认是/usr/bin/

[email protected]:/usr/download/test/mypython$ python

Python 2.7.12 (default, Oct 8 2019, 14:14:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
[‘‘, ‘/opt/stack/keystone‘, ‘/opt/stack/glance‘, ‘/opt/stack/neutron‘, ‘/opt/stack/nova‘, ‘/opt/stack/horizon‘, ‘/opt/ros/kinetic/lib/python2.7/dist-packages‘, ‘/usr/lib/python2.7‘, ‘/usr/lib/python2.7/plat-x86_64-linux-gnu‘, ‘/usr/lib/python2.7/lib-tk‘, ‘/usr/lib/python2.7/lib-old‘, ‘/usr/lib/python2.7/lib-dynload‘, ‘/home/moonx/.local/lib/python2.7/site-packages‘, ‘/usr/local/lib/python2.7/dist-packages‘, ‘/usr/lib/python2.7/dist-packages‘, ‘/usr/lib/python2.7/dist-packages/PILcompat‘, ‘/usr/lib/python2.7/dist-packages/gtk-2.0‘, ‘/usr/lib/python2.7/dist-packages/wx-3.0-gtk2‘]
>>>

二、切换到python的安装目录下,编辑tab键补全模块

[email protected]:/usr/download/test/mypython$ cd /usr/local/lib/python2.7/
  [email protected]:/usr/local/lib/python2.7$ pwd
  /usr/local/lib/python2.7
  [email protected]:/usr/local/lib/python2.7$ vi tab.py

#!/usr/bin/env python
# python startup 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

三、修改~/.bashrc

[email protected]:/usr/local/lib/python2.7$ echo "export PYTHONSTARTUP=/usr/local/lib/python2.7/tab.py" >> ~/.bashrc
[email protected]:/usr/local/lib/python2.7$ source ~/.bashrc

四、进入python测试,可正常使用tab补全功能了

[email protected]:/usr/download/test/mypython$ python
Python 2.7.12 (default, Oct 8 2019, 14:14:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import simple_package
>>> simple_package

原文地址:https://www.cnblogs.com/cjyp/p/11764075.html

时间: 2024-10-16 08:05:01

python tab complete的相关文章

python tab补全

让python的交互解释器支持tab补全.提示功能 方法1: 一.执行python脚本 1.创建一个python脚本,以.py结尾: 脚本如下: import sys import readline import rlcompleter import atexit import os readline.parse_and_bind('tab:complete') histfile =os.path.join(os.environ['HOME'], '.pythonhistory') try: r

python tab

1,www.python.org  下载Python-2.7.10.tgz 安装 2,tab.py #!/usr/bin/env python# python startup fileimport sysimport readlineimport rlcompleterimport atexitimport os# tab completionreadline.parse_and_bind('tab: complete')# history filehistfile = os.path.join

python tab completions

方式一: Ubuntu刚装好命令行中输入命令是没有自动补全的,可以做如下修改增加命令行的命令自动补全功能.修改/etc/bash.bashrc文件 if [ -f /usr/share/bash-completion/bash_completion ]; then . /usr/share/bash-completion/bash_completion elif [ -f /etc/bash_completion ]; then . /etc/bash_completion fi 取消上面几行代

linux下Python tab补全功能代码

1.在学习linux的童鞋都用惯了tab补全功能,从而在学习Python的同时,一是为了方便,二是可以看到更多的关于Python命令下的知识. 2.配置步骤: (1) 在linux下键入这样的代码: vim tab.py #!/usr/bin/python # python tab file import sys import readline import rlcompleter import atexit import os #tab completion readline.parse_an

python tab键补齐

在mac上测试 ipython In [4]: import sys  In [5]: sys.path Out[5]:  ['',  '/usr/local/bin',  '/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg',  '/Library/Python/2.7/site-packages/mysql-0.0.1-py2.7.egg',  '/Library/Python/2.7/site-packages/ipython-3.

python tab键补全

>>> 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/python

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')

Python Tab自动补全

保存路径:/usr/lib/python2.6/site-packages/tab/py 编写python脚本 $ cat tab_enable.py #!/usr/bin/python # python startup file import sys import readline import rlcompleter import atexit import os # tab completion readline.parse_and_bind('tab: complete') # hist

python tab实现

小方法,在这里共享一下. [[email protected] dist-packages]# python Python 2.7.5 (default, Jun 17 2014, 18:11:42) [GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux2 Type "help", "copyright", "credits" or "license" for more inform