我想定期清除 Google Colab 中一个单元格的输出,它运行一个本地 python 文件 !python file.py
!python file.py
我已经在 stackoverflow 上尝试过这个问题的答案:
from google.colab import output output.clear()
和
from IPython.display import clear_output clear_output()
如果我直接在单元格中而不是通过本地文件运行它们,那么这两种方法都可以工作。
python ipython jupyter-notebook google-colaboratory
google-colaboratory ×1
ipython ×1
jupyter-notebook ×1
python ×1