Python基础 (tab自动补全),,Python 自动补


Python 自动补全

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

vim ~/.pythonstartup     #添加如下#!/usr/bin/python import sysimport readlineimport rlcompleterimport atexitimport 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:    passatexit.register(readline.write_history_file, histfile)del os, histfile, readline, rlcompleter

2、添加到~/.bashrc

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

3、测试

[root@python ~]# pythonPython 2.7.11 (default, Mar 29 2016, 23:35:44) [GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2Type "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自动补全)

相关内容

    暂无相关文章

评论关闭