【问题标题】:Python create a Popen shell command listPython 创建 Popen shell 命令列表
【发布时间】:2015-12-03 14:43:46
【问题描述】:

请有人帮我创建一个 Popen 命令行列表...

identify  -format %b:%w:%h:%r:%# myimage.jpg

我有这个:

cmd=Popen(['identify -format', '%b:%w:%h:%r:%#', 'myimage.jpg'])

但这不起作用。原始命令行在命令行中运行良好。但就是不能以这种方式在 python 中工作。

【问题讨论】:

  • 有礼貌地解释你的问题。我们很难知道问题出在哪里。向我们展示一些代码并添加一些示例,还有完整的错误消息
  • 就像我说的我想执行这个命令行参数,以便在 python 中使用 Popen。识别-格式 %b:%w:%h:%r:%# myimage.jpg

标签: python shell subprocess popen


【解决方案1】:

试试这个:

cmd=Popen(['identify', '-format', '%b:%w:%h:%r:%#', 'myimage.jpg'])

您必须将 args 分解为 单独的个参数列表

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-17
    • 2016-03-07
    相关资源
    最近更新 更多