本文介绍了关闭后ipython笔记本保存变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
关闭ipython笔记本后,我意识到所有代码都存在,但命名空间已经重置,就像我所有的变量都消失了一样。
有没有办法可以保存变量,这样当我重新打开ipython笔记本时,变量就在那里而不重新运行代码?
After you close the ipython notebook, I realized all the code is there but the namespace has been reset, as in all of the variables I had were gone.Is there a way I could save the variables so that when I turn ipython notebook back on, the variables are all there without rerunning the code?
推荐答案
使用storemagic命令。
Use the storemagic command.
http://ipython.org/ipython-doc/rel-0.12/config/extensions/storemagic.html
In [1]: l = ['hello',10,'world']
In [2]: %store l
In [3]: exit
(IPython session is closed and started again...)
ville@badger:~$ ipython
In [1]: l
Out[1]: ['hello', 10, 'world']
这篇关于关闭后ipython笔记本保存变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!