|
发表于 2022-7-31 15:42:38
|
显示全部楼层
import os, zipfile
def make_zip(source_dir, output_filename):
zipf = zipfile.ZipFile(output_filename, 'w')
pre_len = len(os.path.dirname(source_dir))
for parent, dirnames, filenames in os.walk(source_dir):
for filename in filenames:
pathfile = os.path.join(parent, filename)
arcname = pathfile[pre_len:].strip(os.path.sep) #相对路径
zipf.write(pathfile, arcname)
zipf.close()
dir = "/content/drive/DeepFaceLab/workspace/" #指定要压缩的文件夹
zipFile = "/content/drive/DeepFaceLab/workspace/" #指定压缩后的文件
make_zip(dir,zipFile) |
|