如何将整个 python 空闲命令历史记录打印到文本文件

How to print the entire python idle commands history to a text file

如何将整个 python 空闲命令历史打印到文本文件。例如我已经输入的命令列表

打印Shell window 的内容与编辑器或输出window 相同。 Select File 然后 Print Window 然后 OK。或者使用快捷键,至少在 Windows 上是 Control-P。我验证了这适用于 Windows with 2.7.13 and 3.6.1.

也可以用FileSave As保存Shell内容,然后编辑结果。如果需要纸质副本,请打印。

https://bugs.python.org/issue11838 是为了让从 shell 日志中获取 运行 代码变得更容易。仅保存用户输入的一个问题是它会丢失回溯中的错误信息。