pyhton tab 自动补全
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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
以上是关于pyhton tab 自动补全的主要内容,如果未能解决你的问题,请参考以下文章
k8s kubectl tab 自动补全,Linux 命令自动补全