代码:

# -*- coding: utf-8 -*-
import os
import zipfile
import platform
import multiprocessing # 解压后的文件夹与原来的zip文件同名且在相同目录下
# 确保windows下解压后的文件夹名不乱码
file_encoding = "utf-8"
if platform.system() == "Windows":
file_encoding = "gbk" # 将zip文件解压到其所在目录
def unzip(file):
file_name, ext = os.path.splitext(file)
if ext == ".zip":
print 'unzip', file
f = zipfile.ZipFile(file)
f.extractall(path=file_name.encode(file_encoding)) # 通过path指定解压的路径 if __name__ == "__main__":
path = raw_input("请输入要解压的zip文件所在目录: ")
print '要解压的zip文件所在目录为:', path
path = path.decode('utf-8') # 不同的系统和平台有各自的编码 ,为了实现系统或平台之间的信息交互可能需要编码转换
# 主要是为了兼容windows ,否则遇到中文路径 会出现 [Errno 2] # 切换到指定目录下
os.chdir(path)
file_list = os.listdir(path) # 获取指定文件夹下的文件列表
pool = multiprocessing.Pool() # 创建进程池
pool.map(unzip, file_list)
pool.close()
pool.join()

最新文章

  1. web前端代码编写体验
  2. 叠罗汉III之推箱子
  3. InActon-日志分析(KPI)
  4. 分享iOS最喜欢的技巧和提示
  5. 大批量DML操作应该注意什么?
  6. bounds的深入研究
  7. 初建FreeMarker工程
  8. Objective-C学习篇04—多态
  9. [LeetCode] 23. 合并K个排序链表
  10. Apache 80端口被占用
  11. CF 1110 D/E
  12. MyEclipse、Eclipse使用配置及部分问题
  13. fixed和sticky
  14. Linux:cut命令详解
  15. 数字证书签发,授权等相关以及https建立通信过程
  16. SQL四大语句、四大完整性、五大约束
  17. 《深入理解JAVA虚拟机》----------第三章 垃圾收集器与内存分配策略,笔记(下)
  18. Synplify9.6.2破解(转帖)
  19. Errors occurred during the build. Errors running builder 'DeploymentBuilder' on project
  20. 2015 UESTC 搜索专题B题 邱老师降临小行星 记忆化搜索

热门文章

  1. 牛客小白月赛12 I 华华和月月逛公园 Tarjan算法求隔边
  2. 『Python CoolBook』C扩展库_其三_简单数组操作
  3. .net代码修改webconfig
  4. Android基础知识(一)
  5. ES5和ES6那些你必须知道的事儿(二)
  6. django中的ORM介绍和字段及字段参数
  7. vscode 创建.net core mvc
  8. Java基础-访问修饰符
  9. OLAP了解与OLAP引擎——Mondrian入门
  10. jQuery-1.样式篇---属性与样式