如何在Google合作实验室中以编程方式清除Python输出?
问题描述:
这个问题是特定于Google Colaboratory的,尽管某些解决方案可能在正常的Python交互器中起作用,但Google Colaboratory似乎不允许我以编程方式清除Python解释器的输出.
This question is specific to Google Colaboratory, while some solutions may work in a normal Python interperter, Google Colaboratory does not seem to allow me to programatically clear the Python interpreter output.
我已经尝试过的解决方案不起作用:
Solutions that I have already tried that do not work:
import os
os.system('cls')
os.system('clear')
!cls
!clear
答
from IPython.display import clear_output
clear_output()
from IPython.display import clear_output
clear_output()
这对我很有用.