• python 批量解压压缩文件


    #/usr/bin/python
    #coding=utf-8
    import os,sys  
    import zipfile
    open_path='e:\data'
    save_path='e:\data'
    os.chdir(open_path)#转到路径
    #首先,通过zipfile模块打开指定位置zip文件
    #传入文件名列表,及列表文件所在路径,及存储路径
    def Decompression(files,file_path,save_path):
        os.getcwd()#当前路径
        os.chdir(file_path)#转到路径
        for file_name in files:
            print(file_name)
            r = zipfile.is_zipfile(file_name)#判断是否解压文件
            if r:
                zpfd = zipfile.ZipFile(file_name)#读取压缩文件
                os.chdir(save_path)#转到存储路径
                zpfd.extractall()
                zpfd.close()

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

    files_save(open_path)

  • 相关阅读:
    HTML5标签
    CTF web之旅 45
    CTF web之旅44
    CTF web之旅 43
    CTF web之旅 42
    CTF web之旅41
    CTF web之旅40
    CTF web之旅 39
    CTF web之旅 38
    CTF web之旅 37
  • 原文地址:https://www.cnblogs.com/niuchen/p/6603526.html
Copyright © 2020-2023  润新知