import zipfile
import tarfile
import os
import shutil
from globimport glob
import sys
def un_zip(path,file_name):
"""unzip zip file"""
zip_file = zipfile.ZipFile(path+file_name)
unzipDir = os.path.splitext(file_name)[0]
print("unzipDir:", unzipDir)
'''
if os.path.isdir(unzipDir):
pass
else:
os.mkdir(unzipDir)
'''
for namesin zip_file.namelist():
print("names:",names)
zip_file.extract(names,path)
zip_file.close()
print(file_name +"解压完成!")
path='F:\matlab-project\Tracker\data\\video\\' #'F:/matlab-project/test/'
files = os.listdir(path)
for file_namein files:
print("file_name:",os.path.splitext(file_name)[1])
if os.path.splitext(file_name)[1] =='.zip':
print("file_name:",file_name)
un_zip(path,file_name)
网友评论