Os.system('cls')

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.

If you are also using javascript, this old notebook cell_density_estimator_for_single_sample.ipynb runs a Bokeh plot and if you save the notebook after running it by launch with this link and then save the notebook & examine the code for producing the output plot you’ll see how it uses javascript to call a clear function that is related. Example:

events.on('clear_output.CodeCell', handleClearOutput);\n",