Feb-05-2021, 04:59 PM
Let's say I have two files, spam.py and eggs.py.
Here's spam.py:
Here's spam.py:
import sys for line in sys.stdin: print(line.upper())And here's eggs.py:
import subprocess process = subprocess.Popen("python ./spam.py", stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) output, errors = process.communicate(b'testing') print(output)Running eggs.py gives this output:
Output:> python eggs.py
b'TESTING\r\n'