import zipfile
import os
def unzip_file(path):
filenames = os.listdir(path)#获取目录下所有文件名
filepath1 = os.path.join(path, "normal")
filepath2 = os.path.join(path, "jdsc")
os.mkdir(filepath1)
os.mkdir(filepath2)
for filename in filenames:
filepath = os.path.join(path,filename)
zip_file = zipfile.ZipFile(filepath) #获取压缩文件
for name in zip_file.namelist():# 解压文件
newfilepath = filepath1
if("jdsc" in name):
newfilepath = filepath2
zip_file.extract(name,newfilepath)
zip_file.close()
print("解压{0}成功".format(filename))
if __name__ == '__main__':
unzip_file(r"D:\JDNetDiskDownload\额外需要处理\压缩")
06-14
665
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-11
336
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-17