Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Clear Python Output Programatically in Google Colaboratory?

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
like image 990
Steven Tang Avatar asked Oct 11 '18 02:10

Steven Tang


People also ask

How do I clear output on Google Colab?

You can select the cell and clear the output by either: Clicking on the clear output button (x) in the toolbar above the cell; or. Right clicking the left gutter of the output area and selecting "Clear output" from the context menu.


2 Answers

from google.colab import output



  output.clear()
like image 165
Aneesh R P Prakkulam Avatar answered Oct 14 '22 06:10

Aneesh R P Prakkulam


from IPython.display import clear_output clear_output()

This is useful to me.

like image 35
二进制 Avatar answered Oct 14 '22 05:10

二进制