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

Python基础 (tab自动补全)

时间:2016-06-29 20:30:09      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:

Python 自动补全

1、添加python自动补全的脚本

vim ~/.pythonstartup     #添加如下
#!/usr/bin/python 
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

2、添加到~/.bashrc

echo ‘export PYTHONSTARTUP="/root/.pythonstartup"‘  >> ~/.bashrc
source ~/.bashrc                      

3、测试

[root@python ~]# python
Python 2.7.11 (default, Mar 29 2016, 23:35:44) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.t                            #tab可以补全
os.tcgetpgrp(  os.tcsetpgrp(  os.tempnam(    os.times(      os.tmpfile(    os.tmpnam(     os.ttyname(    

 

Python基础 (tab自动补全)

标签:

原文地址:http://www.cnblogs.com/huangweimin/p/5628074.html

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