Answer by Aleksandr Tukallo for python loop over subprocess.check_output by line
With Python3 previous answer doesn't work immediately, because bytes are returned by check_output Then you can either decode bytes into a string or split them immediately: output =...
View ArticleAnswer by nicolas.leblanc for python loop over subprocess.check_output by line
subprocess.check_output(['cat', 'foo']) returns a string: "foo\nbar" Thus, your for loop iterates over the string, printing every character, one-by-one. The following should fix your problem: import...
View Articlepython loop over subprocess.check_output by line
I need to loop over the output of a command. I thought I'd use subprocess.check_output, now I have two problems. Here's a file: foo bar Here's my python script: import subprocess for line in...
View ArticleAnswer by Tapio Rantala for python loop over subprocess.check_output by line
Python3:for line in subprocess.check_output(['cat', 'foo'], universal_newlines=True).split('\n'): print(line)
View Article
More Pages to Explore .....