# 将数据解压到workspace/image文件夹
import zipfile
def unzip_file(zip_src, dst_dir):
    r = zipfile.is_zipfile(zip_src)
    if r:     
        fz = zipfile.ZipFile(zip_src, 'r')
        for file in fz.namelist():
            fz.extract(file, dst_dir)       
    else:
        print('This is not zip')
# zip_src源文件夹
# dst_dir目标文件夹
# /home/megstudio/dataset/一般数据集会上传到这个路径
# /home/megstudio/workspace/一定要放到workspace文件夹,才可永久保存
unzip_file(zip_src="/home/megstudio/dataset/dataset-2319/file-1405/train.zip", dst_dir="/home/megstudio/workspace/image")
#压缩文件夹
import zipfile,os

with zipfile.ZipFile('yolo3_pytorch_master.zip','w') as target:
    for i in os.walk('yolo3_pytorch_master'):
        for n in i[2]:
            target.write(''.join((i[0],'/',n))) 
            # windows路径