Print not showing in ipython notebook

后端 未结 3 2028
误落风尘
误落风尘 2020-12-04 16:37

I am using ipython notebook (http://ipython.org/notebook.html) to do a demo and it seems like the print function is not working:

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-04 17:22

    Taking what @JoostJM has said, which works, and putting it as code:

    import sys
    stdout = sys.stdout
    reload(sys)
    sys.setdefaultencoding('utf-8')
    sys.stdout = stdout
    

    Changing the default encoding directs the output to the console, this sets it back to the jupyter notebook.

提交回复
热议问题