您的位置:首页 > 编程语言 > Python开发

python 中TAB空格补全

2017-05-16 21:27 85 查看
直接放到python运行的目录下面,

#pyhton 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

使用方法:

root@kali:~/python# vim tab.py

root@kali:~/python# python

Python 2.7.3 (default, Mar 14 2014, 11:57:14)

[GCC 4.7.2] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> import tab

>>> import sys

>>> sys.                            使用TAB键可以自动查看有关sys.的语句

sys.__class__(              sys.api_version             sys.hexversion

sys.__delattr__(            sys.argv                    sys.long_info

sys.__dict__                sys.builtin_module_names    sys.maxint

sys.__displayhook__(        sys.byteorder               sys.maxsize

sys.__doc__                 sys.call_tracing(           sys.maxunicode

sys.__egginsert             sys.callstats(              sys.meta_path

sys.__excepthook__(         sys.copyright               sys.modules

sys.__format__(             sys.displayhook(            sys.path

sys.__getattribute__(       sys.dont_write_bytecode     sys.path_hooks

sys.__hash__(               sys.exc_clear(              sys.path_importer_cache

sys.__init__(               sys.exc_info(               sys.platform

sys.__name__                sys.exc_type                sys.prefix

sys.__new__(                sys.excepthook(             sys.ps1

sys.__package__             sys.exec_prefix             sys.ps2

sys.__plen                  sys.executable              sys.py3kwarning

sys.__reduce__(             sys.exit(                   sys.pydebug

sys.__reduce_ex__(          sys.exitfunc(               sys.setcheckinterval(

sys.__repr__(               sys.flags                   sys.setdlopenflags(

sys.__setattr__(            sys.float_info              sys.setprofile(

sys.__sizeof__(             sys.float_repr_style        sys.setrecursionlimit(

sys.__stderr__              sys.getcheckinterval(       sys.settrace(

sys.__stdin__               sys.getdefaultencoding(     sys.stderr

sys.__stdout__              sys.getdlopenflags(         sys.stdin

sys.__str__(                sys.getfilesystemencoding(  sys.stdout

sys.__subclasshook__(       sys.getprofile(             sys.subversion

sys._clear_type_cache(      sys.getrecursionlimit(      sys.version

sys._current_frames(        sys.getrefcount(            sys.version_info

sys._getframe(              sys.getsizeof(              sys.warnoptions

sys._mercurial              sys.gettrace(               

>>> sys.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: