How to Clear Python Output Programatically in Goog

2020-07-13 07:45发布

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

2条回答
趁早两清
2楼-- · 2020-07-13 08:03

from IPython.display import clear_output clear_output()

This is useful to me.

查看更多
冷血范
3楼-- · 2020-07-13 08:12

This snippet will halt the current Python runtime and reconnect to a fresh one. (Your filesystem will remain intact.)

import os
os.kill(os.getpid(), 9)
查看更多
登录 后发表回答