IPython Notebook previous cell content

拥有回忆 提交于 2019-12-12 18:24:16

问题


Is it possible in an IPython-Notebook cell to get the previous (above) cell content ?

I can see previous output with %capture magic function but I don't find how to get the previous cell content.


回答1:


I didn't find how to get the previous content cell in a cell.

But I found another solution, creating a custom magic notebook function to capture the cell content and work with that.




回答2:


You can get content of the last executed cell with:

In[len(In)-2]



回答3:


%recall jupyter_notebook_cell_number

Should give you the code that was last executed in indicated particular notebook cell, jupyter_notebook_cell_number



来源:https://stackoverflow.com/questions/27192905/ipython-notebook-previous-cell-content

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