这适用于我的终端:
find "/tmp/pic" \( -iname *.JPG \) | parallel -j 3 convert {} -resize 1920x -quality 60 "/tmp/pic2/{/}"
这不适用于python:
from subprocess import call
import shlex
call(shlex.split('find "/tmp/pic" \( -iname *.JPG \) | parallel -j 3 convert {} -resize 1920x -quality 60 "/tmp/pic2/{/}"'), shell=True)
我发现this的问题有同样的错误。但建议的解决方案(shell=True
)不起作用。 @abarnert描述的os.walk
解决方案听起来合乎逻辑,但我只是想了解我的代码中出了什么问题。
答案 0 :(得分:0)
shell为你做分裂:
from subprocess import call
call('find "/tmp/pic" \( -iname *.JPG \) | parallel -j 3 convert {} -resize 1920x -quality 6\
0 "/tmp/pic2/{/}"', shell=True)