Chinaunix首页 | 论坛 | 博客
  • 博客访问: 386048
  • 博文数量: 112
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 800
  • 用 户 组: 普通用户
  • 注册时间: 2010-12-29 13:41
文章分类

全部博文(112)

文章存档

2020年(1)

2018年(10)

2017年(27)

2016年(18)

2015年(31)

2014年(25)

分类: 系统运维

2016-05-31 00:16:34

方法一:

点击(此处)折叠或打开


  1. vim /usr/lib/python2.6/tab.py 
  2. #!/usr/bin/env python
  3. # python startup file

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

  18. del os, histfile, readline, rlcompleter

  19. # python2.6
  20. >>> import tab
  21. >>> import sys
  22. >>> sys.path
  23. >>> f = file('test')
  24. >>> f.
    f.__class__(         f.__new__(           f.encoding           f.readinto(
    f.__delattr__(       f.__reduce__(        f.errors             f.readline(
    f.__doc__            f.__reduce_ex__(     f.fileno(            f.readlines(
    f.__enter__(         f.__repr__(          f.flush(             f.seek(
    f.__exit__(          f.__setattr__(       f.isatty(            f.softspace
    f.__format__(        f.__sizeof__(        f.mode               f.tell(
    f.__getattribute__(  f.__str__(           f.name               f.truncate(
    f.__hash__(          f.__subclasshook__(  f.newlines           f.write(
    f.__init__(          f.close(             f.next(              f.writelines(
    f.__iter__(          f.closed             f.read(              f.xreadlines(




方法二:
  

点击(此处)折叠或打开

  1. 编辑一个~/.py_tab.py(名字可任意起),输入以下内容:
  2. import readline
    import rlcompleter
    readline.parse_and_bind("tab: complete")

  3. 设置环境变量~/.bashrc
  4. export PYTHONSTARTUP=~/.py_tab.py
  5. 重启当前shell.



Windows 7下配置python3的tab补全功能;

点击(此处)折叠或打开

  1. #首先安装readline模块
  2. pip install pyreadline
  3. 编辑C:\Python3\Lib\tab.py文件,内容如下:
  4. import readline
    import rlcompleter
    readline.parse_and_bind('tab: complete')





阅读(1103) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~