📅  最后修改于: 2022-03-11 14:45:37.449000             🧑  作者: Mango
import tarfile
import os.path
def make_tarfile(output_filename, source_dir):
with tarfile.open(output_filename, "w:gz") as tar:
tar.add(source_dir, arcname=os.path.basename(source_dir))