PYTHON批量解压ZIP并删除源ZIP文件

           zpfd = zipfile.ZipFile(file_name)#读取压缩文件
            os.chdir(output_path)#转到存储路径
            zpfd.extractall()
            zpfd.close()

def files_save(input_path):
    for file_path,sub_dirs,files in os.walk(input_path):#获取所有文件名,路径
        print(file_path,sub_dirs,files)
        dc(files,file_path,output_path)

def del_file(path):
    ls = os.listdir(path)
    for i in ls:
        if (i[-3:])=='zip':
            c_path = os.path.join(path, i)
            if os.path.isdir(c_path):
                del_file(c_path)
                print(c_path)
            else:
                os.remove(c_path)
                print(c_path)



files_save(input_path)
del_file(input_path)

你可能感兴趣的:(PYTHON)