How to use jupyter_client to get the execute result?

北城以北 提交于 2019-12-11 04:47:31

问题


I'd like to use jupyter_client to execute some python code and get result. Here's my sample code. But I could not get the output hello world, Could anyone help me ? Thanks

import jupyter_client
kernel_manager, kernel_client = jupyter_client.manager.start_new_kernel(kernel_name='python3')
kernel_client.execute("print('hello world')")
kernel_client.get_shell_msg() 

回答1:


The output wont be on the standard output, it will be in a result object. Check this snippet: https://www.snip2code.com/Snippet/1169700/sample-code-for-jupyter_client



来源:https://stackoverflow.com/questions/44866686/how-to-use-jupyter-client-to-get-the-execute-result

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