您如何在交互式 Python 中查看整个命令历史记录? [英] How do you see the entire command history in interactive Python?
本文介绍了您如何在交互式 Python 中查看整个命令历史记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在 Mac OS X 上使用默认的 Python 解释器,并且我 Cmd+K(清除)我之前的命令.我可以使用箭头键一一浏览它们.但是有没有像 bash shell 中的 --history 选项这样的选项,它会显示你到目前为止输入的所有命令?
I'm working on the default python interpreter on Mac OS X, and I Cmd+K (cleared) my earlier commands. I can go through them one by one using the arrow keys. But is there an option like the --history option in bash shell, which shows you all the commands you've entered so far?
推荐答案
使用 <代码>readline.get_current_history_length() 获取长度,readline.get_history_item()
查看每一个.
Use readline.get_current_history_length()
to get the length, and readline.get_history_item()
to view each.
这篇关于您如何在交互式 Python 中查看整个命令历史记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文