Let's say I have an example perl
program, that I can run from CMD (Windows 7) using the command:
perl hello.pl
This outputs:
Hello World!
I can place this in a file using:
perl hello.pl > output.txt
However, what I would like to do, is give it to another application, for this I need it to be fed to a Python application. I give arguments to my Python application using the syntax:
python python.py Arg1 Arg2 Arg3
Assuming my Perl program only gives one parameter, is there a way to run a Python application once it has finished with this parameter?
Make your python program read the output from the perl program from sys.stdin
and pipe the perl program's stdout to it:
perl hello.pl | python python.py Arg1 Arg2 Arg3
I tested this going from one python program to another and in the second python program just did:
import sys
inp = sys.stdin.readline()
print(inp)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.