Home > Mobile >  from subprocess import check_output - what does it mean
from subprocess import check_output - what does it mean

Time:01-30

from subprocess import check_output I'm unable to understand the purpose of this line in jupyter notebook. Can someone please explain me why do we need this library in simple words. What I am trying to understand is what would check_output do?

CodePudding user response:

Without seeing what is being done in the jupyter notebook, it is rather hard to say.

That being said, it is simply importing the check_output class from the subprocess module.

I am not intimate enough with this library

CodePudding user response:

I am not familiar with this library, but from the research I did, it is for collecting the response to commands run on the console.

Example:

import subprocess
result = subprocess.check_output(["echo", "Hello World!"], shell=True)
print(result)

b'"Hello World!"\r\n'
from subprocess import check_output
result = check_output(["python", "--version"], shell=True)
print(result)

b'Python 3.9.6\r\n'
  •  Tags:  
  • Related