【问题标题】:How to see the console history of all commands in the IPython console in Spyder如何在 Spyder 的 IPython 控制台中查看所有命令的控制台历史记录
【发布时间】:2017-02-23 19:28:13
【问题描述】:

在 Spyder 的 IPython 控制台中,我只能看到最新执行的命令——因为前者从控制台窗口中消失了。

我想知道是否有某种方式--e.g.通过调整一些参数——在 Spyder 的 IPython 控制台中查看所有命令的控制台历史记录。

你能帮帮我吗?谢谢!

【问题讨论】:

    标签: console stack ipython spyder


    【解决方案1】:

    如果您在 Ipython 控制台中输入 %quickref,您将看到如下所示的部分:

    History:
    
    _i, _ii, _iii    : Previous, next previous, next next previous input
    _i4, _ih[2:5]    : Input history line 4, lines 2-4
    exec _i81        : Execute input history line #81 again
    %rep 81          : Edit input history line #81
    _, __, ___       : previous, next previous, next next previous output
    _dh              : Directory history
    _oh              : Output history
    %hist            : Command history of current session.
    %hist -g foo     : Search command history of (almost) all sessions for 'foo'.
    %hist -g         : Command history of (almost) all sessions.
    %hist 1/2-8      : Command history containing lines 2-8 of session 1.
    %hist 1/ ~2/     : Command history of session 1 and 2 sessions before current.
    %hist ~8/1-~6/5  : Command history from line 1 of 8 sessions ago to
                       line 5 of 6 sessions ago.
    %edit 0/         : Open editor to execute code with history of current session.
    

    其中一个命令应该执行您想要的操作...

    【讨论】:

    • %hist 是 OP 问题的答案。
    【解决方案2】:

    我遇到了相同/类似的问题 - 计算机重新启动并在 spyder 中丢失了未保存的代码(我没有使用 ipython)

    在以下位置找到历史文件:

    "C:\Users\my_username\.spyder-py3\history.py"
    

    (如果您有其他版本,请查找.spyderXXXXXX

    hist -g 可能只显示有限数量的行 - 可能是因为 console print limit。如果您将hist -g 的结果与hist -g some_word 的结果进行比较(例如hist -g import)。你会看到hist -g import 显示了一些早于hist -g 的行。这表明hist 显示的行数有限。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-01
      • 1970-01-01
      • 2017-07-26
      • 2011-11-16
      • 2016-01-13
      • 1970-01-01
      • 2015-05-11
      • 1970-01-01
      相关资源
      最近更新 更多