...

/

Learning to Communicate with subprocess

Learning to Communicate with subprocess

How to communicate with the subprocess in Python

We'll cover the following...

There are several ways to communicate with the process you have invoked. We’re just going to focus on how to use the subprocess module’s communicate method. Let’s take a look:

Press + to interact
import subprocess
args = ["du"]
process = subprocess.Popen(args,
stdout=subprocess.PIPE)
data = process.communicate()
print(data)

In this code example, we create an args variable to hold our ...