Movatterモバイル変換


[0]ホーム

URL:


Loading video player…

Using the Python subprocess Module (Overview)

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.
Download

Course Slides (.pdf)

2.4 MB
Download

Sample Code (.zip)

891 bytes

00:00Hey, hello and welcome to this course.This course is about using the Pythonsubprocess module.subprocess is one of those modules that doesn’t tendto get people very excited,but I think those people are wrong.

00:15subprocess is a very cool module.I think it gives you superpowers. Why superpowers?Well,subprocess allows you to interactwith your operating system from within a Python application.

00:28Now, how cool is that? Do you want to run a shell command,for example, or you want to launch another program,or automate some command-line tools,or automate Git commandsor chain commands together using pipes?

00:43You can do all that and much more withsubprocess,and this course will get you started.

00:50So what is it you will be learning?Well, you’ll learn how to use therun() function of thissubprocess module.You’ll also learn how to handlesubprocess exceptions, howto communicate with processes, how to implement pipes,and firstly, we’ll touch on what are pipes.

01:10And then finally there is the use of thePopen()constructor of thesubprocess module.

01:18Now, this is in a bit more detail.We’ll go through the overview of thesubprocess module,then you will learn the basic usage of the module.

01:27Then there are thosesubprocess exceptions, communicationwith processes, pipes, and thePopen class.Now I’m very excited to go on this journey with you.

01:38Let’s get started.

Become a Member to join the conversation.

Course Contents

Overview
6%

[8]ページ先頭

©2009-2026 Movatter.jp