IPython Notebook previous cell content

2019-07-17 16:27发布

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.

3条回答
祖国的老花朵
2楼-- · 2019-07-17 16:48
%recall jupyter_notebook_cell_number

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

查看更多
老娘就宠你
3楼-- · 2019-07-17 17:05

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.

查看更多
Explosion°爆炸
4楼-- · 2019-07-17 17:06

You can get content of the last executed cell with:

In[len(In)-2]
查看更多
登录 后发表回答