How to Clear Python Output Programatically in Google Colaboratory?

北城余情 提交于 2019-12-07 10:51:29

问题


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

回答1:


from IPython.display import clear_output clear_output()

This is useful to me.




回答2:


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)


来源:https://stackoverflow.com/questions/52751413/how-to-clear-python-output-programatically-in-google-colaboratory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!