程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

The python zipfile library decompresses all zip files in a certain path

編輯:Python

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 .


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved