today , Data sets engaged in machine learning encounter zip, Try to use python decompression , I saw Big brother's article , I improved myself , Record a wave by the way .
The code is as follows :
#encoding="utf-8"
#@Author:Mr.Pan_ Academic mania
#finish_time:2022/2/15
import sys
import gzip
import os
import zipfile
def zip_process(path):
# path = 'G:/DeepLearning/data/'
if os.path.exists(path):
dirs = os.listdir(path)
# print(dirs)
for dir in dirs:
if '.zip' in dir:
filename = dir.replace(".zip","")
zip = zipfile.ZipFile(path+dir)
zip.extractall(path+filename)
zip.close()
if __name__ == '__main__':
zip_process('G:/DeepLearning/data/')
Running results :
Last , Thank you for coming to watch my article , There may be many inadequacies in the text , I also hope to point out and sea culvert .