Movatterモバイル変換


[0]ホーム

URL:


The subprocess Module: Wrapping Program With Python

Using the Python subprocess Module

Steven Loyens
Steven Loyens14 Lessons 40m May 06, 2025intermediatestdlib
Start Now
Rate and Review

Python’ssubprocess module allows you to run shell commands and manage external processes directly from your Python code. By usingsubprocess, you can execute shell commands likels ordir, launch applications, and handle both input and output streams. This module provides tools for error handling and process communication, making it a flexible choice for integrating command-line operations into your Python projects.

By the end of this video course, you’ll understand that:

  • The Pythonsubprocess module is used torun shell commands and manage external processes.
  • You run a shell command usingsubprocess bycallingsubprocess.run() with the command as a list of arguments.
  • subprocess.call(),subprocess.run(), andsubprocess.Popen() differ inhow they execute commands and handle process output and return codes.
  • multiprocessing is forparallel execution within Python, whilesubprocess managesexternal processes.
  • To execute multiple commands in sequence usingsubprocess, you can chain them byusing pipes or running them consecutively.

What’s Included:

Downloadable Resources:

Related Learning Paths:

Start Now

Getting Started With subprocess

8 Lessons 20m

  1. 1. Using the Python subprocess Module (Overview)01:40
  2. 2. Learning the subprocess Module03:11
  3. 3. Getting Started With the subprocess Module02:48
  4. 4. Using subprocess to Run Python02:03
  5. 5. Using subprocess to Run Any App01:40
  6. 6. Understanding the CompletedProcess Object02:43
  7. 7. Exploring Exceptions03:40
  8. 8. Raising a TimeoutExpired Error02:39

Streams and Pipes

6 Lessons 20m

  1. 1. Communicating With Standard IO Streams01:45
  2. 2. Decoding of Standard Streams06:01
  3. 3. Introducing Pipes03:23
  4. 4. Simulating Pipes With run()02:13
  5. 5. Creating Pipes With Popen06:00
  6. 6. Using the Python subprocess Module (Summary)00:47
Start Now

AboutSteven Loyens

Steven is an Actuary, Economist and Engineer who found his passion for coding messing about with his Commodore 64 in the eighties. He loves understanding how things work and sharing that knowledge. He's an experienced coach and mentor.

» More about Steven

Each tutorial at Real Python is created by a team of developers so that it meets our high quality standards. The team members who worked on this tutorial are:

Related Courses:

← Browse All Courses


[8]ページ先頭

©2009-2026 Movatter.jp