1.安装readline模块。
sudo apt-get install readline*
# 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 3.在~/.bash_profile中添加环境变量
export PYTHONSTARTUP=~/.pythonstartup4.刷新配置
source .bash_profile
原文地址:http://blog.csdn.net/apache0554/article/details/44830003