how to use os.system(‘cls’) in jupyter notebook? I want to make a text gif~
I think you are looking for IPython/Jupyter’s
clear_output, documented here.
Quick demo to run in a notebook cell:
from IPython.display import clear_output import time for i in range(10): clear_output(wait=True) print("Hello World!") time.sleep(2) clear_output(wait=True) print("Enjoy World!") time.sleep(2)
More examples I stumbled upon here.
There is an ‘animated’ plot among the examples there. (Add the the two first lines from my quick demo to make it work.)
For related animated plots, I often use clearing the canvas itself (I haven’t explored if behind the scenes
clear_output is used), see examples and links to other related resources and examples herein. Click
launch binder there to get started.