ipython notebook save variables after closing

2019-07-04 05:45发布

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条回答
Summer. ? 凉城
2楼-- · 2019-07-04 06:03

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']
查看更多
登录 后发表回答