简体   繁体   English

iPython有效命令的历史记录

[英]iPython history of valid commands

I am learning python using IPython. 我正在使用IPython学习python。 When I did something nice I like to copy this into some kind of private CheatSheet-file. 当我做一些不错的事情时,我喜欢将其复制到某种私有的CheatSheet文件中。 Therefore I use the iPython %hist command. 因此,我使用了iPython %hist命令。 I am wondering, if there is a way to only print those commands which had been syntactically correct and did not raise an error. 我想知道,是否有办法只打印那些语法正确且没有引发错误的命令。 Any ideas? 有任何想法吗?

Have you considered trying ipython notebook ? 您是否考虑过尝试使用ipython Notebook? (I've used it on a couple of training courses) (我已经在一些培训课程中使用过它)

You access the interatctive python via a web browser creating 'boxes' of runnable code. 您可以通过网络浏览器创建可运行代码的“框”来访问交互式Python。 So if you ran a block, it gave the answer you wanted and threw no errors, you could then create another block and move on (preserving the bit you wished to keep). 因此,如果您运行一个块,它会给出您想要的答案,并且没有抛出任何错误,那么您可以创建另一个块并继续(保留您希望保留的位)。 If it threw an error or didn't produce the expected result, you could edit and re-run until it did. 如果它抛出错误或没有产生预期的结果,则可以编辑并重新运行直到出现错误。

Your boxes of code can be interspersed with html markup notes, graphs, diagrams - you name it. 您的代码框可以插入html标记注释,图形,图表-命名即可。 The whole notebook can then be saved for later access and re-run when re-loaded. 然后可以保存整个笔记本以供以后访问,并在重新加载后重新运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM