码迷,mamicode.com
首页 > 编程语言 > 详细

python的tab自动补全

时间:2016-12-25 14:07:49      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:ror   write   查看   tor   atexit   parse   ubuntu   his   pass   

 

vi tab.py
#!/usr/bin/env python 
# python 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

 

代码有了,我们还需要将脚本放到python指定的目录下,可以使用sys.path来查看一下

>>> import sys
>>> sys.path
[‘‘, /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, /usr/lib/python2.7/dist-packages/ubuntu-sso-client]
  一般我们会将这一类代码放在/usr/local/lib/python2.7/dist-packages目录下

 

mv tab.py /usr/lib64/python2.7/site-packages/

 

python的tab自动补全

标签:ror   write   查看   tor   atexit   parse   ubuntu   his   pass   

原文地址:http://www.cnblogs.com/sysk/p/6219363.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!