On this page
  1. subprocess.check_output
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

subprocess.check_output

Prev: subprocess.check_call | Up: subprocess | Next: subprocess.CompletedProcess
Rel: subprocess.call, subprocess.CalledProcessError, subprocess.check_call, subprocess.CompletedProcess
Ref: docs.python.org — subprocess.check_output
Tags: #public #python3 #stdlib #subprocess


Import

import subprocess
from subprocess import check_output

Signature & Overview

subprocess.check_output(*popenargs, timeout=None, **kwargs)

Run command with arguments and return its output.

Usage

import subprocess
import sys

out = subprocess.check_output([sys.executable, "-c", "print('hi')"], text=True)
assert out.strip() == "hi"

Gotchas

REPL Inspect

from subprocess import check_output
help(check_output)

Linked from

Related notes