如何保存python会话输入和输出 [英] how to save python session input and output

查看:97
本文介绍了如何保存python会话输入和输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

讨论这个问题的所有方法都将命令的历史记录保存在文件中,或者您必须使用 IDE,我正在使用带有 python 模式的 vim(不使用鼠标)我想做的是保存我的会话作为我编写的代码和 python 输出,所以我不必使用纸和笔来编写我的输入和 python 输出,我所要做的就是打印我的会话,我尝试了代码(.pystartup)它只保存我的输入,我试图将输出重定向到一个文件,它只保存 python 输出,有没有办法让两个文件都准备好打印出来.

All of the ways which discussed this question save the history of your commands in a file or you have to use an IDE ,I am using vim with python-mode (no mouse using) what I would like to do is to save my session as code I wrote and the python output ,So I dont have to use paper and pen to write my input and python output all what I have to do is to print out my session , I tried the code (.pystartup) and it only save my input and I tried to redirect the output to a file and it only save the python output , is there a way to have both in one file ready to be printed out .

推荐答案

我真的很珍惜 vim,这是一件很棒的工作.不过,使用其他工具可以更轻松地满足您的要求.

I really cherish vim, it'S a fantastic piece of work. Nevertheless, your requirements are easier with other tools.

在我看来,最好的选择可能是使用 ipython notebook.它提供了非常丰富的功能,包括带有 mpl 的图形等等,对我来说是可重复实验"的完美工具.可以将笔记本的完整状态保存到磁盘、重新加载、导出、打印等.

Probably the best choice, in my oppinion, would be to use the ipython notebook. It offers really rich features, including graphics with mpl and much more, and for me is the perfect tool for "reproducible experiments". The full state of a notebook can be saved to disk, reloaded, exported, printed etc.

你真的应该试一试.

这篇关于如何保存python会话输入和输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆