【问题标题】:Executing a bash command line inside a python function [duplicate]在python函数中执行bash命令行[重复]
【发布时间】:2020-06-10 20:43:52
【问题描述】:

我想实现一个 python 函数来执行一个 bash 命令。 例如:

def run_command():
# run 'python test --a' command

【问题讨论】:

  • 你做过任何研究吗?
  • 您可能希望/需要确保 Bash 运行它,例如 bash -c 'python test --a',具体取决于您选择的方法(请参阅副本)

标签: python bash command-line


【解决方案1】:

这就是你要找的吗?

import subprocess
subprocess.call("--command here--")

【讨论】:

    猜你喜欢
    • 2016-02-20
    • 2018-06-12
    • 1970-01-01
    • 2017-11-30
    • 1970-01-01
    • 1970-01-01
    • 2016-10-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多