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.
  • 相关阅读:
    让windows10的右键菜单既显示传统cmd又显示powershell
    配置php环境的一个nginx.conf
    windows中启动和终止nginx的两个批处理
    WxWidgets笔记
    安装archlinux的linux命令记录
    window中的attrib命令
    docker中i的作用
    airflow中的两个参数
    sqlite数据库中为字段设置默认值为当前时间
    记oracle使用expdp将数据导出到asm报错
  • 原文地址:https://www.cnblogs.com/TooyLee/p/7736927.html
Copyright © 2011-2022 走看看