subprocess — Subprocess management — Python 3.9.25 documentation

docs.python.org

Tin mới

Replacing os.system()¶

Calling the program through the shell is usually not required.

concurrent.futures — Launching parallel tasks

sched — Event scheduler

Python documentation for the current stable release

Python documentation for the current stable release

The subprocess module allows you to spawn new processes, connect to their input/output/error pipes, and obtain their return codes. This module intends to replace several older modules and functions:

Python Module Index

3.9.25 Documentation

The Python Standard Library

Concurrent Execution

glob: Unix shell style pathname pattern expansion.

If encoding or errors are specified, or text (also known as universal_newlines) is true, the file objects stdin, stdout and stderr will be opened in text mode using the encoding and errors specified in the call or the de

fnmatch: Unix shell style filename pattern matching.

If encoding or errors are specified, or text (also known as universal_newlines) is true, the file objects stdin, stdout and stderr will be opened in text mode using the encoding and errors specified in the call or the de

os.path.expandvars()

If encoding or errors are specified, or text (also known as universal_newlines) is true, the file objects stdin, stdout and stderr will be opened in text mode using the encoding and errors specified in the call or the de

shutil: High-level file operations, including copying.

If encoding or errors are specified, or text (also known as universal_newlines) is true, the file objects stdin, stdout and stderr will be opened in text mode using the encoding and errors specified in the call or the de

locale.getpreferredencoding(False)

Changed in version 3.3: When universal_newlines is True, the class uses the encoding locale.getpreferredencoding(False) instead of locale.getpreferredencoding(). See the io.TextIOWrapper class for more information on thi

Security Considerations¶

Unlike some other popen functions, this library will not implicitly choose to call a system shell. This means that all characters, including shell metacharacters, can safely be passed to child processes. If the shell is

asyncio: Asynchronous I/O.

The function is implemented using a busy loop (non-blocking call and short sleeps). Use the asyncio module for an asynchronous wait: see asyncio.create_subprocess_exec.

asyncio.create_subprocess_exec

The function is implemented using a busy loop (non-blocking call and short sleeps). Use the asyncio module for an asynchronous wait: see asyncio.create_subprocess_exec.