如何将Stdin发送到Ipython?
我在尝试通过STDIN将数据发送到Ipython时很难,似乎EOF被解释为Ipython的退出命令吗?
示例:
echo'“ hello”'| ipython
,
Python 3.9.2 (default, Feb 28 2021, 17:03:44)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.2.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: Out[1]: 'hello'
In [2]: Do you really want to exit ([y]/n)?
并且该过程在没有我做其他任何事情的情况下退出。
是否有要设置的参数?
编辑:为了使上下文更清晰,我想做的实际情况如下:
program1 | ipython -i -c“%运行脚本”
program1将输出某些内容(json),而ipython会运行一个将东西加载到我可以使用的东西中的脚本,然后让我进入我可以玩的ipython解释器与它。
I'm having trouble trying to send data through stdin to IPython, it seems that EOF is interpreted as an exit command for ipython ?
Example:
echo '"hello"' |ipython
Python 3.9.2 (default, Feb 28 2021, 17:03:44)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.2.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: Out[1]: 'hello'
In [2]: Do you really want to exit ([y]/n)?
And the process quits without me doing anything else.
Is there a parameter to set or something ?
Edit: To make the context clearer, the real scenario where I want to do this is the following:
program1 | ipython -i -c "%run script"
program1 would output something (a json), and ipython would run a script that load the thing into something I can use, then leave me to a IPython interpreter where I can play with it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
与评论相同。您的问题还不清楚。
也许将某些python命令送到python interter?
尝试此
尝试将执行
a = 123
,并将Python进入相互作用模式,该模式将您的键盘输入输入Same as comment. your question is quite unclear.
Maybe pipe some python command to a python interperter?
try this
this will execute
a=123
and make python into interative mode which take your keyboard input