Man*_*uel 7 metadata ipython-notebook
我想以IPython.html.widgets某种方式将我的值存储在我的ipython笔记本中。
有没有办法从单元格自身中的代码修改当前单元格的元数据?
我不知道如何在笔记本中执行此操作,但是我找到了一种通过自定义操作执行此操作的方法 预处理器和nbconvert的方法。
您可以创建扩展nbconvert.preprocessors.ExecutePreprocessor的类。在preprocess(或preprocess_cell)方法中,添加用于将相关输出存储在单元元数据中的逻辑。
就像是:
class MyExecutePreprocessor(ExecutePreprocessor):
def preprocess_cell(self, cell, resources, index):
# Execute the cell normally
cell, resources = super().preprocess_cell(cell, resources, index)
# Add your magic here
cell.metadata['widgets'] = {'stuff':'that is cool'}
return cell, resources
Run Code Online (Sandbox Code Playgroud)
然后,您可以以编程方式或作为nbconvert的参数来执行此预处理器。
如果我明白您要查找的内容:从Cell Toolbar(ipython 笔记本工具栏的右上角)的Edit Metadata下拉列表中进行选择。
| 归档时间: |
|
| 查看次数: |
3125 次 |
| 最近记录: |