码迷,mamicode.com
首页 > 数据库 > 详细

python解压,压缩,以及存数据库的相关操作

时间:2018-02-02 20:20:26      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:ref   实现   util   csdn   lob   input   ret   style   数据   

zipfile实现压缩整个目录和子目录

技术分享图片
import os,shutil,zipfile,glob

def dfs_get_zip_file(input_path,result):

#
    files = os.listdir(input_path)
    for file in files:
        if os.path.isdir(input_path+/+file):
            dfs_get_zip_file(input_path+/+file,result)
        else:
            result.append(input_path+/+file)

def zip_path(input_path,output_path,output_name):

    f = zipfile.ZipFile(output_path+/+output_name,w,zipfile.ZIP_DEFLATED)
    filelists = []
    dfs_get_zip_file(input_path,filelists)
    for file in filelists:
        f.write(file)
    f.close()
    return output_path+r"/"+output_name

zip_path(r"./10",D:,wok.zip)
View Code

 

python解压,压缩,以及存数据库的相关操作

标签:ref   实现   util   csdn   lob   input   ret   style   数据   

原文地址:https://www.cnblogs.com/vactor/p/8406437.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!