PythonからLinuxコマンド実行 – python subprocess –

subprocess – Subprocess management – Python 3.9.1 documentation

Source code: Lib/subprocess.py The 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: Information about how the module can be used to replace these modules and functions can be found in the following sections.

あんまりないかもしれないけど、PythonからLinuxコマンドを実行する方法。

import subprocess
  
subprocess.run(["ls", "-l"])
subprocess.run(["docker", "ps"])