简体   繁体   English

在ipython笔记本中管理stdout和stdin

[英]Manage stdout and stdin in ipython notebook

A short ipython notebook cell: 一个简短的ipython笔记本电池:

%%bash    
read value
5
echo "Value: $value"

The output for this cell is Value: 5 Is possible to introduce the value interactively using the ipython notebook? 此单元格的输出值为Value: 5是否可以使用ipython笔记本以交互方式引入值?

If now I try to run this: 如果现在我尝试运行这个:

%%bash
ssh user@host pwd

since is the first time trying to connect to host , ssh launches the question: 因为是第一次尝试连接到host ,ssh启动了这个问题:

Are you sure you want to continue connecting (yes/no)?

But this question is printed in the shell where I started the ipython notebook, and not in the notebook itself. 但是这个问题打印在我启动ipython笔记本的shell中,而不是在笔记本本身。 And here I can write the answer in the shell. 在这里,我可以在shell中写出答案。

Would be possible to display the output and also introduce my answer through the notebook web interface? 可以显示输出并通过笔记本网络界面介绍我的答案吗?

This is a frustrating aspect of the notebook, but there's a (now merged) pull request to provide the ability to do interactive stdin within the notebook. 这是笔记本电脑的一个令人沮丧的方面,但有一个(现在已合并) 拉取请求,以提供在笔记本电脑中进行交互式标准输入的能力。 To make use of this you'd have to install the master branch I believe. 要使用它,你必须安装我相信的master分支。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM