ipython notebook clear cell output in code

前端 未结 3 1043
深忆病人
深忆病人 2020-12-02 06:07

In a iPython notebook, I have a while loop that listens to a Serial port and print the received data in real time.

What I want to achieve to only show t

3条回答
  •  离开以前
    2020-12-02 06:33

    You can use the IPython.display.clear_output to clear the output as mentioned in cel's answer. I would add that for me the best solution was to use this combination of parameters to print without any "shakiness" of the notebook:

    from IPython.display import clear_output
    
    for i in range(10):
        clear_output(wait=True)
        print(i, flush=True)
    

提交回复
热议问题