• python中的tab补全功能添加


    1.先准备一个tab.py的脚本

    #!usr/bin/python
    # python tab 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默认的模块存放地址

    ➜  xushukui python
    Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
    [GCC 5.4.0 20160609] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import sys
    >>> sys.path
    ['', '/usr/local/lib/python2.7/dist-packages/greenlet-0.4.12-py2.7-linux-x86_64.egg', '/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', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/gtk-2.0']
    >>> 
    

    3.拷贝该脚本到默认模块存放路径
    cp tab.py /usr/lib/python2.7

    4.然后可以用了

    >>> import tab
    >>> import sys
    >>> sys.
    sys.__class__(              sys._multiarch              sys.gettrace(
    sys.__delattr__(            sys.api_version             sys.hexversion
    sys.__dict__                sys.argv                    sys.long_info
    sys.__displayhook__(        sys.builtin_module_names    sys.maxint
    sys.__doc__                 sys.byteorder               sys.maxsize
    sys.__egginsert             sys.call_tracing(           sys.maxunicode
    sys.__excepthook__(         sys.callstats(              sys.meta_path
    sys.__format__(             sys.copyright               sys.modules
    sys.__getattribute__(       sys.displayhook(            sys.path
    sys.__hash__(               sys.dont_write_bytecode     sys.path_hooks
    sys.__init__(               sys.exc_clear(              sys.path_importer_cache
    sys.__name__                sys.exc_info(               sys.platform
    sys.__new__(                sys.exc_type                sys.prefix
    sys.__package__             sys.excepthook(             sys.ps1
    sys.__plen                  sys.exec_prefix             sys.ps2
    sys.__reduce__(             sys.executable              sys.py3kwarning
    sys.__reduce_ex__(          sys.exit(                   sys.pydebug
    sys.__repr__(               sys.exitfunc(               sys.setcheckinterval(
    sys.__setattr__(            sys.flags                   sys.setdlopenflags(
    sys.__sizeof__(             sys.float_info              sys.setprofile(
    sys.__stderr__              sys.float_repr_style        sys.setrecursionlimit(
    sys.__stdin__               sys.getcheckinterval(       sys.settrace(
    sys.__stdout__              sys.getdefaultencoding(     sys.stderr
    sys.__str__(                sys.getdlopenflags(         sys.stdin
    sys.__subclasshook__(       sys.getfilesystemencoding(  sys.stdout
    sys._clear_type_cache(      sys.getprofile(             sys.subversion
    sys._current_frames(        sys.getrecursionlimit(      sys.version
    sys._getframe(              sys.getrefcount(            sys.version_info
    sys._mercurial              sys.getsizeof(              sys.warnoptions
    
  • 相关阅读:
    MongoDB知识
    SELECT INTO 和 INSERT INTO SELECT 两种表复制语句
    SQL Server 触发器
    TSQL游标使用
    python和C#的区别
    bcp和SqlDataAdapter进行批量跟新插入方法
    SQL Server中索引视图用法详解
    hdu 1950 Bridging signals
    UVA 116 Unidirectional TSP
    poj 3230 Travel
  • 原文地址:https://www.cnblogs.com/nyist-xsk/p/7380083.html
Copyright © 2020-2023  润新知