我想编写一个Python文件,用Python提取tar文件。
据我了解,subprocess
是这个任务的合适工具。
我写下了以下代码:
from subprocess import call
def tarfile(path):
call(["tar"], path)
if __name__ == "__main__":
tarfile("/root/tryit/output.tar")
当输出为tar文件时,它位于/root/tryit/
中。
运行时,我收到以下消息:
TypeError: bufsize must be an integer
我能用tar命令和这个工具一起使用吗?