pyhton tab 自动补全

1.创建tab.py
[[email protected] files]# cat 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
2.查看Python默认的模块存放地址
[[email protected] files]# python
Python 2.7.8 (default, Dec 29 2016, 11:45:52) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> import sys
>>> sys.path
[‘‘, ‘/usr/local/lib/python2.7/site-packages/setuptools-7.0-py2.7.egg‘, ‘/usr/local/lib/python2.7/site-packages/MarkupSafe-0.9.3-py2.7-linux-x86_64.egg‘, ‘/usr/local/lib/python2.7/site-packages/paramiko-1.15.1-py2.7.egg‘, ‘/usr/local/lib/python2.7/site-packages/simplejson-3.6.5-py2.7-linux-x86_64.egg‘, ‘/usr/local/lib/python2.7/site-packages/ansible-2.0.0.0-py2.7.egg‘, ‘/usr/local/lib/python2.7/site-packages/Jinja2-2.8-py2.7.egg‘, ‘/usr/local/lib/python27.zip‘, ‘/usr/local/lib/python2.7‘, ‘/usr/local/lib/python2.7/plat-linux2‘, ‘/usr/local/lib/python2.7/lib-tk‘, ‘/usr/local/lib/python2.7/lib-old‘, ‘/usr/local/lib/python2.7/lib-dynload‘, ‘/usr/local/lib/python2.7/site-packages‘]
3. 拷贝该脚本到默认模块存放路径
[[email protected] files]# cp tab.py /usr/local/lib/python2.7
4. 测试
[[email protected] files]# python
Python 2.7.8 (default, Dec 29 2016, 11:45:52) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tab
>>> import sys
>>> sys.
sys.__class__(              sys.__stdout__              sys.exit(                   sys.path_hooks
sys.__delattr__(            sys.__str__(                sys.exitfunc(               sys.path_importer_cache
sys.__dict__                sys.__subclasshook__(       sys.flags                   sys.platform
sys.__displayhook__(        sys._clear_type_cache(      sys.float_info              sys.prefix
sys.__doc__                 sys._current_frames(        sys.float_repr_style        sys.ps1
sys.__egginsert             sys._getframe(              sys.getcheckinterval(       sys.ps2
sys.__excepthook__(         sys._mercurial              sys.getdefaultencoding(     sys.py3kwarning
sys.__format__(             sys.api_version             sys.getdlopenflags(         sys.setcheckinterval(
sys.__getattribute__(       sys.argv                    sys.getfilesystemencoding(  sys.setdlopenflags(
sys.__hash__(               sys.builtin_module_names    sys.getprofile(             sys.setprofile(
sys.__init__(               sys.byteorder               sys.getrecursionlimit(      sys.setrecursionlimit(
sys.__name__                sys.call_tracing(           sys.getrefcount(            sys.settrace(
sys.__new__(                sys.callstats(              sys.getsizeof(              sys.stderr
时间: 2024-08-02 05:37:05

pyhton tab 自动补全的相关文章

python的tab自动补全

很久不写blog了. 最近发现python的自动补全是个好东西. 分享一下. 参考了:http://www.cnblogs.com/allenblogs/archive/2011/04/21/2023288.html 和 软件手册 下载地址:http://vim.sourceforge.net/scripts/script.php?script_id=850 直接粘贴了. ------------------------------ vim编辑器中 #mkdir -p ~/.vim/after/

python2.7 tab,自动补全

python <tab>自动补全 一.这个方法可以修改shell命令行的自动补全 1.获取python目录[我使用的是64位ubuntu系统] [~$]python Python 2.7.3 (default, Apr 10 2013, 06:20:15) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more 

CentOs6.5 更新python2.7,以及tab自动补全

#安装python2.7之前,准备工作: yum install python-devel gcc patch readline* -y #解压并安装: tar xf Python-2.7.10.tar.xz cd Python-2.7.10 sed -i 's/#readline/readline/g' Modules/Setup.dist ./configure --prefix=/usr/local/python make && make install #更改系统python调用

sudo和man的tab自动补全

要加入sudo和man的tab自动补全功能,只需在~/.bashrc中加入: #Enabling tab-completioncomplete -cf sudocomplete -cf man

python交互模式下的tab自动补全

python在交互模式下,输入命令的时候按tab键就按时间tab键的功能输出,在书写python时多有不便. 把下面的代码写入一个文件tab.py,放到/usr/lib/python2.6/site-packages/下 #!/usr/bin/env python import sys import readline import rlcompleter import atexit import os readline.parse_and_bind('tab:complete') histfil

使用tab自动补全mysql命令

1.使用mysql --help查看mysql的命令参数 注意 --auto-rehash       Enable automatic rehashing. One doesn't need to use 'rehash' to get table and field completion, but startup and reconnecting may take a longer time. Disable with --disable-auto-rehash. (Defaults to

Python基础 (tab自动补全)

Python 自动补全 1.添加python自动补全的脚本 vim ~/.pythonstartup #添加如下 #!/usr/bin/python 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.envir

vs code使用tab自动补全html代码

使用tab键完成自动补全,提高开发速度. 第一步 下载emmet插件 第二步 打开设置文件setting.json 第三步 完成对seting.json的配置 // 启用后,按 TAB 键时,将展开 Emmet 缩写. "emmet.triggerExpansionOnTab": true, // 添加需要补全的文档格式 "emmet.syntaxProfiles": { "javascript": "jsx", "

Mac Tab自动补全键

最近入手一个Mac(Mac 2019版本),在使用终端时,发现不能使用Tab键自动补全代码,网络搜寻下,发现这里有个方法,记录下,免得自己忘记: 1 / 首先找到这个图标 2 / 输入命令 nano .inputrc 打开文件,在文件输入以下内容 set completion-ignore-case on set show-all-if-ambiguous on TAB: menu-complete 然后 按住control + o,再点击回车键,重启终端即可. 原文地址:https://www