当然可以,只需一个小的启动脚本。从交互式输入编辑及历史替换在Python教程:
# Add auto-completion and a stored history file of commands to your Python# interactive interpreter. Requires Python 2.0+, readline. Autocomplete is# bound to the Esc key by default (you can change it - see readline docs).## Store the file in ~/.pystartup, and set an environment variable to point# to it: "export PYTHonSTARTUP=~/.pystartup" in bash.import atexitimport osimport readlineimport rlcompleterhistoryPath = os.path.expanduser("~/.pyhistory")def save_history(historyPath=historyPath): import readline readline.write_history_file(historyPath)if os.path.exists(historyPath): readline.read_history_file(historyPath)atexit.register(save_history)del os, atexit, readline, rlcompleter, save_history, historyPath从Python
3.4开始,交互式解释器开箱即用地支持自动完成和历史记录:
现在,在支持的系统上的交互式解释器中,默认情况下启用了制表符完成功能
readline。默认情况下,历史记录也处于启用状态,并且被写入文件(或从文件中读取)~/.python-history。



