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

交互模式下python自动补全

2015-07-20 20:33 721 查看
打开当前主目录

cd ~



新建文件 vim .pythonstartup

<pre name="code" class="python">import rlcompleter
import readline
import atexit
import os

# http://stackoverflow.com/questions/7116038/python-tab-completion-mac-osx-10-7-lion if 'libedit' in readline.__doc__:
readline.parse_and_bind('bind ^I rl_complete')
else:
readline.parse_and_bind('tab: complete')

histfile = os.path.join(os.environ['HOME'], '.pyhist')
try:
readline.read_history_file(histfile)
except IOError:
pass
atexit.register(readline.write_history_file, histfile)

del readline, rlcompleter, histfile, os



保存退出

加入环境变量:

echo 'export PYTHONSTARTUP=~/.pythonstartup' >> ~/.bash_profile


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