Make ipython notebook print in real time

前端 未结 3 1991
终归单人心
终归单人心 2021-01-01 13:12

Ipython Notebook doesn\'t seem to print results in real time, but seems to buffer in a certain way and then bulk output the prints. How can I make ipython print my results a

3条回答
  •  暖寄归人
    2021-01-01 13:57

    Since Python 3.3, print() has an additional flush argument that can be used to force flushing:

    for i in range(10):
        print(i, flush=True)
        time.sleep(1)  
    

提交回复
热议问题