管道到ipython

在python中,我可以执行以下操作,并且效果很好:

$ echo "hello world"| python -c "import sys; print(''.join(sys.stdin))"
hello world

现在,我想使用ipython console

以类似的方式使用ipython
$ echo "hello world"| ipython console <<< "import sys; print(''.join(sys.stdin))"
[TerminalIPythonApp] WARNING | Subcommand `ipython console` is deprecated and will be removed in future versions.
[TerminalIPythonApp] WARNING | You likely want to use `jupyter console` in the future
Warning: Input is not to a terminal (fd=0).
Jupyter console 6.0.0

Python 3.6.7 (default,Oct 22 2018,11:32:17)
Type 'copyright','credits' or 'license' for more information
IPython 7.8.0 -- An enhanced Interactive Python. Type '?' for help.



In [1]: hello world
  File "<ipython-input-1-22596363b3de>",line 1
    hello world
              ^
SyntaxError: invalid syntax


In [2]: import sys; print(''.join(sys.stdin))


In [3]:
Do you really want to exit ([y]/n)?
Shutting down kernel

为什么ipython console?长话短说:我正在后台运行我的命令的内核,发现的方式是通过ipython console --existing <<< "python instructions....",但是我还想通过管道传输其他命令的输出...

rree2009 回答:管道到ipython

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3086499.html

大家都在问