zoukankan      html  css  js  c++  java
  • python解压压缩包

    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: 是zip文件的全路径
    dst_dir: 是要解压到的目的文件夹

    2.压缩指定文件夹

    def zip_file(src_dir):
      zip_name = src_dir +'.zip'
      z = zipfile.ZipFile(zip_name,'w',zipfile.ZIP_DEFLATED)
      for dirpath, dirnames, filenames in os.walk(src_dir):
        fpath = dirpath.replace(src_dir,'')
        fpath = fpath and fpath + os.sep or ''
        for filename in filenames:
          z.write(os.path.join(dirpath, filename),fpath+filename)
          print ('==压缩成功==')
      z.close()

    原文链接:https://blog.csdn.net/weixin_43593330/article/details/103869090

  • 相关阅读:
    MR架构
    概念词汇
    数仓项目06:DWD层
    Informatic学习总结_day03
    oracle_创建和管理表
    oracle_使用子查询创建表
    oracle数据类型
    文本变语音引擎 ekho
    [LNOI2014]LCA
    POJ 2942 Knights of the Round Table
  • 原文地址:https://www.cnblogs.com/ArdenWang/p/14689108.html
Copyright © 2011-2022 走看看