模块常用snippet

压缩,文件操作,数据库,md5,json,

压缩

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))

 

转载于:https://www.cnblogs.com/willaty/p/8005864.html

你可能感兴趣的:(c/c++)