Python create a Popen shell command list

2020-05-10 01:55发布

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

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

I have this:

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

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.

1条回答
兄弟一词,经得起流年.
2楼-- · 2020-05-10 02:43

try this:

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

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

查看更多
登录 后发表回答