Nguyễn Thuỳ Chi
New member
How do you run a Python command in Linux and output?
Answer
A better way to get the output from executing a linux command in Python is to use
Python module “subprocess”
. Here is an example of using “subprocess” to count the number of lines in a file using “wc -l” linux command. Launch the shell command that we want to execute using subprocess. Popen function.
Answer
A better way to get the output from executing a linux command in Python is to use
Python module “subprocess”
. Here is an example of using “subprocess” to count the number of lines in a file using “wc -l” linux command. Launch the shell command that we want to execute using subprocess. Popen function.