ipython notebook 关闭后保存变量
ipython notebook save variables after closing
关闭 ipython 笔记本后,我意识到所有代码都在那里,但名称空间已被重置,因为我拥有的所有变量都消失了。
有没有一种方法可以保存变量,这样当我重新打开 ipython notebook 时,变量都在那里而无需重新运行代码?
使用 storemagic 命令。
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 笔记本后,我意识到所有代码都在那里,但名称空间已被重置,因为我拥有的所有变量都消失了。 有没有一种方法可以保存变量,这样当我重新打开 ipython notebook 时,变量都在那里而无需重新运行代码?
使用 storemagic 命令。
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']