"incorect command line error" 当通过子进程压缩文件时
"incorect command line error" when compressing file via subprocess
我需要通过子进程和 7z.exe 压缩一批文件。他们的名字以“-”开头。
看来7z不能接受。其他“+”开头的文件没有问题。
有解决办法吗?
谢谢!
import os
import subprocess
subprocess.call(['7z.exe', 'a', '-01+005_compressed.txt', '-01+005_orig.txt', '-mx9'], shell=True)
错误:
命令行不正确
在文件名前添加一个--
,以防止将后续参数识别为标志:
subprocess.call(['7z.exe', 'a', '--', '-01+005_compressed.txt', '-01+005_orig.txt', '-mx9'], shell=True)
我需要通过子进程和 7z.exe 压缩一批文件。他们的名字以“-”开头。 看来7z不能接受。其他“+”开头的文件没有问题。
有解决办法吗?
谢谢!
import os
import subprocess
subprocess.call(['7z.exe', 'a', '-01+005_compressed.txt', '-01+005_orig.txt', '-mx9'], shell=True)
错误:
命令行不正确
在文件名前添加一个--
,以防止将后续参数识别为标志:
subprocess.call(['7z.exe', 'a', '--', '-01+005_compressed.txt', '-01+005_orig.txt', '-mx9'], shell=True)