我正在处理 Windows 10 上的默认 python 解释器,我可以使用箭头键一一浏览它们。但是有没有像 bash shell 中的 history 命令这样的选项,它会显示你到目前为止输入的所有命令?
这几乎是 How do you see the entire command history in interactive Python? 的副本,除了 它适用于 Windows 10 而不是 macos/*nix。那里的解决方案要么推荐 iPython,我不经常使用它,要么使用 readline,它在 Windows 上不可用。
I have installed the pyreadline package ,但在这种情况下它似乎不是替代品。

C:\Users\yoder>python
Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

最佳答案

总结一下 ErykSun 和 Vova 在关于这个问题的评论中所说的话:
如果您在 cmd 提示符下运行 Python 并且尚未安装 pyreadline ,则可以按 F7 以调出 cmd 的 native 历史记录,Python 将其用于自己的历史记录。
如果您已经安装了 pyreadline ,那么您可以 import readline 并使用 this answer 中描述的技术。

关于python - 从 Windows 上的交互式提示打印 Python 历史记录,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/62802667/

10-14 17:20
查看更多