zip文件是我们经常使用的打包格式之一,python解压和压缩zip效率非凡。 python解压zip文档:
复制代码 代码如下:
import os,sys,time
import zipfile
filename = 'callofdutyblackopszombies_1349649132343_my.zip' #要解压的文件
filedir = 'data/' #解压后放入的目录
r = zipfile.is_zipfile(filename)
if r:
starttime = time.time()
fz = zipfile.ZipFile(filename,'r')
for file in fz.namelist():
print(file) #打印zip归档中目录
fz.extract(file,filedir)
endtime = time.time()
times = endtime - starttime
else:
print('This file is not zip file')
print('times' + str(times))
Copyright© 2013-2020
All Rights Reserved 京ICP备2023019179号-8