如何使用jupyter_client获取执行结果? [英] How to use jupyter_client to get the execute result?

查看:869
本文介绍了如何使用jupyter_client获取执行结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用jupyter_client来执行一些python代码并获得结果。这是我的示例代码。但我无法得到输出 hello world ,有人能帮助我吗?谢谢

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() 


推荐答案

输出不在标准输出上,它将在结果对象中。请查看以下代码段:
https://www.snip2code。 com / Snippet / 1169700 / sample-code-for-jupyter_client

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

这篇关于如何使用jupyter_client获取执行结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆