![]() ![]() Run operating system commands and display the results directly on the standard output device( ie: screen console).Run Shell Command Use os Module system And popen Function. > import subprocessī'openjdk version "1.8.0_212"\nOpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_212-b03)\nOpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.212-b03, mixed mode)\n' 2. Below is another example that runs a command java -version to get the currently installed java version. ![]() Then we can get the subprocess execution result output text using the child process’s stdout read() method.> child = subprocess.Popen(, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # the child process will print it's standard output to a pipe line, the pipe line connect the child process and it's parent process. Then we should create a child process object using the subprocess module’s Popen method and assign it to a variable.First, we should import the subprocess module.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |