在 Windows' cmd.exe shell 中,如何将 Perl 脚本的输出通过管道传输到 Python 脚本?

In Windows' cmd.exe shell, how can I pipe the output of a Perl script to a Python script?

假设我有一个示例 perl 程序,我可以 运行 从 CMD (Windows 7) 使用命令:

perl hello.pl

这输出:

你好世界!

我可以使用以下方法将其放入文件中:

perl hello.pl > output.txt

但是,我想做的是将它提供给另一个应用程序,为此我需要将它提供给 Python 应用程序。我使用以下语法为 Python 应用程序提供参数:

python python.py Arg1 Arg2 Arg3

假设我的 Perl 程序只给出一个参数,有没有办法在完成此参数后 运行 一个 Python 应用程序?

让您的 python 程序从 sys.stdin 读取 perl 程序的输出,并将 perl 程序的标准输出通过管道传递给它:

perl hello.pl | python python.py Arg1 Arg2 Arg3

我测试了从一个 python 程序到另一个 python 程序,在第二个 python 程序中:

import sys

inp = sys.stdin.readline()
print(inp)