python subprocess

Starting a subprocess in python ?

To start a new process, you can use Popen function. The args includes program you want to start, second is file.

from subprocess import Popen, PIPEprocess = Popen(['cat', 'main.py'], stdout=PIPE, stderr=PIPE)stdout, stderr = process.communicate()print(stdout)
class Hello{public static void main(String args[]){System.out.print("Java says Hello World!");}}
import subprocessimport osdef Java_Execution():# storing the outputs = subprocess.check_output("javac Hello.java;java Hello", shell = True)print(s.decode("utf-8"))# Driver functionsif __name__=="__main__":Java_Execution()

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store