zoukankan      html  css  js  c++  java
  • 在Ubuntu16.04中python环境下实现tab键补全

    1.编写tab.py的代码:

     1 #!/usr/bin/env python
     2 # python startup file 
     3 import sys
     4 import readline
     5 import rlcompleter
     6 import atexit
     7 import os
     8 # tab completion 
     9 readline.parse_and_bind('tab: complete')
    10 # history file 
    11 histfile = os.path.join(os.environ['HOME'], '.pythonhistory')
    12 try:
    13     readline.read_history_file(histfile)
    14 except IOError:
    15     pass
    16 atexit.register(readline.write_history_file, histfile)
    17 del os, histfile, readline, rlcompleter

     2.把上面的代码,保存成tab.py文件,然后保存到下面的指定路径之一:

    >>> import sys
    >>> sys.path
    ['', '/home/hhl/dev/catkin_ws/devel/lib/python2.7/dist-packages', '/home/hhl/catkin_ws/devel/lib/python2.7/dist-packages', '/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', '/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']

    3.使用:导入tab模块,可以使用tab键补全功能,例如:

    >>> import tab
    >>> import sys
    >>> sys.
    sys.__class__(              sys.exit(
    sys.__delattr__(            sys.exitfunc(
    sys.__dict__                sys.flags
    sys.__displayhook__(        sys.float_info
    sys.__doc__                 sys.float_repr_style
    sys.__excepthook__(         sys.getcheckinterval(
    sys.__format__(             sys.getdefaultencoding(
    sys.__getattribute__(       sys.getdlopenflags(
    sys.__hash__(               sys.getfilesystemencoding(
    sys.__init__(               sys.getprofile(
    sys.__name__                sys.getrecursionlimit(
    sys.__new__(                sys.getrefcount(
    sys.__package__             sys.getsizeof(
    sys.__reduce__(             sys.gettrace(
    sys.__reduce_ex__(          sys.hexversion
    sys.__repr__(               sys.long_info
    sys.__setattr__(            sys.maxint
    sys.__sizeof__(             sys.maxsize
    sys.__stderr__              sys.maxunicode
    sys.__stdin__               sys.meta_path
    sys.__stdout__              sys.modules
    sys.__str__(                sys.path
    sys.__subclasshook__(       sys.path_hooks
    sys._clear_type_cache(      sys.path_importer_cache
    sys._current_frames(        sys.platform
    sys._getframe(              sys.prefix
    sys._mercurial              sys.ps1
    sys._multiarch              sys.ps2
    sys.api_version             sys.py3kwarning
    sys.argv                    sys.pydebug
    sys.builtin_module_names    sys.setcheckinterval(
    sys.byteorder               sys.setdlopenflags(
    sys.call_tracing(           sys.setprofile(
    sys.callstats(              sys.setrecursionlimit(
    sys.copyright               sys.settrace(
    sys.displayhook(            sys.stderr
    sys.dont_write_bytecode     sys.stdin
    sys.exc_clear(              sys.stdout
    sys.exc_info(               sys.subversion
    sys.exc_type                sys.version
    sys.excepthook(             sys.version_info
    sys.exec_prefix             sys.warnoptions
    sys.executable              
    >>> sys.
  • 相关阅读:
    PAT 1097. Deduplication on a Linked List (链表)
    PAT 1096. Consecutive Factors
    PAT 1095. Cars on Campus
    PAT 1094. The Largest Generation (层级遍历)
    PAT 1093. Count PAT's
    PAT 1092. To Buy or Not to Buy
    PAT 1091. Acute Stroke (bfs)
    CSS:word-wrap/overflow/transition
    node-webkit中的requirejs报错问题:path must be a string error in Require.js
    script加载之defer和async
  • 原文地址:https://www.cnblogs.com/TooyLee/p/7736927.html
Copyright © 2011-2022 走看看