python压缩解压文件(天地图切片批量解压缩)
import zipfile import os src_path = r"D: est estdir" dsc_path = r"D: est estdir.zip" extr_path = r"D: est ew_testdir" #压缩文件 z = zipfile.ZipFile(dsc_path , "w") for root, dirs, files in os.walk(src_path): for file in files: z.write( os.path.join( root, file ) ) z.close() #一定要关闭 #解压文件 with zipfile.ZipFile(dsc_path, mode="a") as f: f.extractall(extr_path) f.close() #一定要关闭