【问题标题】:How to use jupyter_client to get the execute result?如何使用 jupyter_client 获取执行结果?
【发布时间】:2017-07-02 01:18:50
【问题描述】:

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

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

【问题讨论】:

    标签: python ipython jupyter


    【解决方案1】:

    输出不会在标准输出上,而是在结果对象中。检查这个sn-p: https://www.snip2code.com/Snippet/1169700/sample-code-for-jupyter_client

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-21
      • 1970-01-01
      相关资源
      最近更新 更多