标签:history python except 用户 export
在用户目录下创建.pythonstartup文件,输入如下脚本
# 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
输入
export PYTHONSTARTUP=~/.pythonstartup
编辑用户目录下的
.bash_profile,最后加入下列命令
export PYTHONSTARTUP=~/.pythonstartup
标签:history python except 用户 export
原文地址:http://duanran.blog.51cto.com/1129646/1909313