IPython Notebook - Keep printing to notebook output after closing browser

牧云@^-^@ 提交于 2019-11-30 12:51:55

Well, found an ok solution. Solution is in this file: https://github.com/QUVA-Lab/artemis/blob/master/artemis/fileman/persistent_print.py

With example use: https://github.com/QUVA-Lab/artemis/blob/master/artemis/fileman/test_persistent_print.py

The demo now looks like:

import time
from general.persistent_print import capture_print, reprint
capture_print()
start_time = time.time()
for i in xrange(5):
    print '%s seconds have passed' % (time.time()-start_time)
    time.sleep(2)
print 'Done!'

And if I run

reprint()

In the next cell, it will redisplay all the print statements made since capture_print was called. Obviously it would be better if this were unnecessary, but it works for now.

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