tar
有一个-C
(--directory
)选项,使它在开始处理文件之前改变目录。
subprocess.call(['tar',
'-C', '/path/to/file/',
'-zcvf',
'/path/to/destination/myfile.tar.gz', "myfile.bin"])
See the tar
man page详情请见下文。
你可以用cwd
的参数来完成同样的事情,即subprocess.call
。
subprocess.call(['tar',