Python创建一个Popen Shell命令列表 [英] Python create a Popen shell command list

查看:98
本文介绍了Python创建一个Popen Shell命令列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请有人帮我从此创建Popen命令行列表...

Please can someone help me create a Popen command line list from this...

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

我有这个:

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

但这不起作用.原始命令行在命令行中可以正常工作.但是只是无法使其以这种方式在python中工作.

But that does not work. the original command line works fine in the command line. But just cannot get it working in python this way.

推荐答案

尝试一下:

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

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

you have to break down args as a list of separate arguments

这篇关于Python创建一个Popen Shell命令列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆