ipython notebook save variables after closing

寵の児 提交于 2019-12-23 17:13:14

问题


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?


回答1:


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']


来源:https://stackoverflow.com/questions/32210951/ipython-notebook-save-variables-after-closing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!