gpt4 book ai didi

Python 子进程 : how to use pipes thrice?

转载 作者:太空狗 更新时间:2023-10-29 17:55:11 24 4
gpt4 key购买 nike

<分区>

我想在以下行中使用子流程:

convert ../loxie-orig.png bmp:- | mkbitmap -f 2 -s 2 -t 0.48 | potrace -t 5 --progress -s -o ../DSC00232.svg

我找到了感谢其他帖子the subprocess documentation但在示例中我们只使用了两次管道。

所以,我尝试了三个命令中的两个,它起作用了

p1 = subprocess.Popen(['convert', fileIn, 'bmp:-'], stdout=subprocess.PIPE)
# p2 = subprocess.Popen(['mkbitmap', '-f', '2', '-s', '2', '-t', '0.48'], stdout=subprocess.PIPE)
p3 = subprocess.Popen(['potrace', '-t' , '5', '-s' , '-o', fileOut], stdin=p1.stdout,stdout=subprocess.PIPE)
p1.stdout.close() # Allow p1 to receive a SIGPIPE if p3 exits.
output = p3.communicate()[0]

你能帮我完成第三条命令吗?

非常感谢。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com