如何在Python中获取tarfile
对象的二进制表示?现在我正在做以下事情,但这涉及“复制”:
with BytesIO() as out_buffer:
with tarfile.open(fileobj=out_buffer, mode='w') as newtar:
for member in data:
newtar.addfile(member, data.extractfile(member))
tar_binary = out_buffer.getvalue()