如何从 IDLE 访问命令历史记录?

发布于 2024-09-06 22:28:36 字数 217 浏览 1 评论 0原文

在 bash 或 Window 的命令提示符下,我们可以按键盘上的向上箭头获取最后一条命令,然后对其进行编辑,然后再次按 ENTER 键查看结果。

但在Python的IDLE 2.6.5或3.1.2中,似乎如果我们的语句打印出25行,我们需要按向上箭头25次到最后一个命令,然后按ENTER键才能复制它?

或者使用鼠标精确定位该行并单击该处,然后按 ENTER 进行复制?有更快的方法吗?

On bash or Window's Command Prompt, we can press the up arrow on keyboard to get the last command, and edit it, and press ENTER again to see the result.

But in Python's IDLE 2.6.5 or 3.1.2, it seems if our statement prints out 25 lines, we need to press the up arrow 25 times to that last command, and press ENTER for it to be copied?

Or use the mouse to pinpoint that line and click there, and press ENTER to copy? Is there a faster way?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

囚我心虐我身 2024-09-13 22:28:36
  • 我认为您正在寻找 history-previous action,即
    默认情况下绑定到 Alt+P
  • 您可以在“选项 -> 配置 IDLE -> 键”中重新映射它。
  • 您还可以从 IDLE 的顶部菜单访问此命令:“Shell -> 历史记录 >”

顺便说一句,你为什么不尝试一个更好的(对于初学者来说不那么难看)shell,比如 bpython< /a> 或 ipython

  • I think you are looking for the history-previous action, which is
    bound to Alt+P by default.
  • You can remap it in "Options -> Configure IDLE -> Keys"
  • You can also access this command from the top menu in IDLE: "Shell -> Previous History"

Incidentally, why don't you try a better (less ugly, for starters) shell like bpython or ipython?

陈独秀 2024-09-13 22:28:36

只需使用Alt+P即可向上。同样,Alt+N 可用于向下移动。

just use Alt+P to go up. Similarly, Alt+N could be used to go down.

幸福丶如此 2024-09-13 22:28:36

如果您使用的是 Mac,则为 ctrl+p

If you're on mac, it's ctrl+p.

葮薆情 2024-09-13 22:28:36

进入首选项>钥匙。在列表中找到“历史上一个”选项并将其编辑为向上箭头。

空闲设置

Go into Preferences > Keys. Find the 'history-previous' selection in the list and edit it to Up Arrow.

Idle settings

拿命拼未来 2024-09-13 22:28:36

默认情况下,您可以随时编辑 ~/.idlerc 下的 config-keys.cfg 文件;查找条目“history-previous”并将其设置为如下...

history-previous = <Key-Up>

完成。

You can always edit the file config-keys.cfg found under ~/.idlerc by default; look for the entry "history-previous" and set it to as below...

history-previous = <Key-Up>

Done.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文