python 交互界面tab补全

创建一个tab.py文件

代码:

#!/usr/bin/env python

import readline
import rlcompleter
import atexit
import os

# tab completion

readline.parse_and_bind(‘tab:complete‘)

#history file

historyfile = os.path.join(os.environ[‘HOME‘],‘.tab‘)

try:
    readline.read_history_file(historyfile)
except:
    pass

atexit.register(readline.write_history_file,historyfile)

del os,historyfile,readline,rlcompleter

>>> import sys
>>> sys.path
[‘‘, ‘/usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg‘, ‘/usr/lib64/python27.zip‘, ‘/usr/lib64/python2.7‘, ‘/usr/lib64/python2.7/plat-linux2‘, ‘/usr/lib64/python2.7/lib-tk‘, ‘/usr/lib64/python2.7/lib-old‘, ‘/usr/lib64/python2.7/lib-dynload‘, ‘/usr/lib64/python2.7/site-packages‘, ‘/usr/lib64/python2.7/site-packages/gtk-2.0‘, ‘/usr/lib/python2.7/site-packages‘]

将tab.py复制到 /usr/lib64/python2.7/site-packages 下

>>> import tab
>>> os.
就可以补全了

时间: 2024-10-10 13:34:03

python 交互界面tab补全的相关文章

Python 中的tab补全

用Python时候没有TAB补全,挺痛苦的,以下是添加方法 1.准备一个Python脚本 cat > tab.py <<EOF#!/usr/local/bin/python# python tab file import sysimport readlineimport rlcompleterimport atexitimport os# tab completionreadline.parse_and_bind('tab: complete')# history filehistfil

python安装及其tab补全

声明,普通linux系统都是自带python,若是2.7的版本,就用着吧,若不是建议先卸载再安装. 1.下载安装包 wget  https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tgz 2.解压安装 tar -zxvf Python-2.7.9.tgz cd Python-2.7.9 yum –y install readline-devel  (上下左右功能) ./configure make &&make install 3.Ta

Python中的Tab补全

刚开始学习Python的时候,没有tab补全是一件很痛苦的事情.tab补全的代码如下: # Python startupfile Import sys Import readline Import rlcompleter Import os   Readline.parse_and_bind('tab:complete') Histfile = os.path.join(os.environ['HOME'],'pythonhistory') 将其移动到/usr/lib/python2.7/dis

python中使用tab补全

要能够使用import tab,最主要的是要有readline模块.默认python2.6虽然没有装tab模块,但是装了readline模块的.如下: [[email protected] robin]# python2.6Python 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",

python交互环境tab补齐

>>> import sys >>> sys.path ['', '/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg', '/usr/lib64/python26.zip', '/usr/lib64/python2.6', '/usr/lib64/python2.6/plat-linux2', '/usr/lib64/python2.6/lib-tk', '/usr/lib64/python2.6/

python交互模式下命令tab补全

python默认就可以进行tab补全命令行,在交互模式下,只要自己写个小小的tab.py模块即可:实现代码如下: #!/bin/env python  # -*- coding: utf-8 -*- # python startup file  import sys import readline import rlcompleter import atexit import os import platform # tab completion  readline.parse_and_bind

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补全

文章摘自:http://www.jb51.net/article/58009.htm 第一.如在在vim下实现代码的补全功能. 想要为vim实现自动补全功能,则要下载插件 cd /usr/local/src wget https://github.com/rkulla/pydiction/archive/master.zip unzip -q master mkdir -p ~/.vim/tools/pydiction cp -r pydiction/after ~/.vim cp pydict

Python相关环境设置tab补全

1.Windows下使用PyCharm下默认就含有tab补全 2.Python for Window 3.Python for Mac [email protected]:~/python$ cat tab.py import sys import readline import rlcompleter if sys.platform == 'darwin' and sys.version_info[0] == 2:     readline.parse_and_bind("bind ^I rl