您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

如何在python解释器外壳中重复上一条命令?

如何在python解释器外壳中重复上一条命令?

我使用以下命令在python shell上启用历史记录。

这是我的 文件。PYTHONSTARTUP环境变量设置为此文件路径。

# python startup file 
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

您将需要使模块readline rlcompleter启用此功能

在以下网址查看有关此信息:http : //docs.python.org/using/cmdline.html#envvar- PYTHONSTARTUP。

所需模块:

python 2022/1/1 18:49:49 有434人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶