python run command line

纯净搜索 为您找到 本页 4 条,用时 5.55 秒(数据源:360)

AI 回答 由 glm-4-flash 生成 · 仅供参考,请自行核实
1. 使用 `subprocess` 模块运行命令行:

import subprocess

subprocess.run(["command", "arg1", "arg2"], check=True)

2. 使用 `os` 模块运行命令行:

import os

os.system("command arg1 arg2")

3. 使用 `subprocess.Popen` 运行命令行:

import subprocess

process = subprocess.Popen(["command", "arg1", "arg2"], stdout=subprocess.PIPE)
stdout, stderr = process.communicate()

相关搜索