Jupyter notebook 如何捕获cell';在Databricks笔记本中的输出

Jupyter notebook 如何捕获cell';在Databricks笔记本中的输出,jupyter-notebook,databricks,azure-databricks,Jupyter Notebook,Databricks,Azure Databricks,我尝试使用:%%捕获我的\u cap 但它给出了一个错误: TypeError: run_cell() missing 1 required positional argument: 'raw_cell' 所以它不可用:-(第一个单元格中的其他选项包括: from IPython.utils.capture import CapturedIO capture = CapturedIO(sys.stdout, sys.stderr) ... ... # at the end of desi

我尝试使用:
%%捕获我的\u cap
但它给出了一个错误:

TypeError: run_cell() missing 1 required positional argument: 'raw_cell'

所以它不可用:-(第一个单元格中的其他选项包括:

from IPython.utils.capture import CapturedIO   
capture = CapturedIO(sys.stdout, sys.stderr)
...
...
# at the end of desired output:
cmem = capture.stdout
在第二个单元格中,您可以访问变量
cmem

print(cmem)

很高兴知道您的问题已经解决。您可以接受它作为答案(单击答案旁边的复选标记将其从灰色切换为已填写)。这对其他社区成员有益。谢谢。