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?
just use Alt+P
to go up. Similarly, Alt+N
could be used to go down.
If you're on mac, it's ctrl+p.
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.
来源:https://stackoverflow.com/questions/3132265/how-do-i-access-the-command-history-from-idle