import os,shutil,zipfile,glob def dfs_get_zip_file(input_path,result): # files = os.listdir(input_path) for file in files: if os.path.isdir(input_path+‘/‘+file): dfs_get_zip_file(input_path+‘/‘+file,result) else: result.append(input_path+‘/‘+file) def zip_path(input_path,output_path,output_name): f = zipfile.ZipFile(output_path+‘/‘+output_name,‘w‘,zipfile.ZIP_DEFLATED) filelists = [] dfs_get_zip_file(input_path,filelists) for file in filelists: f.write(file) f.close() return output_path+r"/"+output_name zip_path(r"./10",‘D:‘,‘wok.zip‘)
原文地址:https://www.cnblogs.com/vactor/p/8406437.html
时间: 2024-11-05 13:29:38