Python 压缩文件(1),python压缩文件,import os i
文章由Byrx.net分享于2019-03-23 09:03:40
Python 压缩文件(1),python压缩文件,import os i
import os import threading, zipfile class AsyncZip(threading.Thread): def __init__ (self, infile, outfile): threading.Thread. __init__ (self) self.infile = infile self.outfile = outfile def run(self): state = ' w ' if os.path.isfile(self.outfile) == True: state = ' a ' f = zipfile.ZipFile(self.outfile, state, zipfile.ZIP_DEFLATED) f.write(self.infile) f.close() print ' Finished background zip of: ' , self.infile def zipDir(src,dst): initPath = os.getcwd() tempDST = os.path.join(os.getcwd(),dst) tempSRC = os.path.join(os.getcwd(),src) os.chdir( tempSRC ) files = os.listdir(os.curdir) print files for file in files: background = AsyncZip(file,dst) background.start() background.join() # Wait for the background task to finish os.chdir( initPath ) print os.getcwd() # test ok if __name__ == ' __main__ ' : zipDir( " D:\\\\AutoUpdate\\\\DataDist\\\\viruswall\\\\Data\\\\KSVW-VirusDB\\\\ " , " d:\\\\AutoUpdate\\\\DataDist\\\\viruswall\\\\Data\\\\update\\\\KSVW-VirusDB.tgz " )#该片段来自于http://byrx.net
相关内容
- python抓取百度音乐盒榜单的音乐,python抓取,[Python]代码
- python登录猫扑打卡,python猫扑打卡,[Python]代码#
- RhinoScript,,付表皮# -*- cod
- python Web 框架bottle超清晰使用范例,pythonbottle,#coding:
- 一个Python的交互式解释器,python解释器,因为在安卓上装
- 用python正则表达式提取网页的url,python正则表达式,im
- 获取上一个月最后一天的日期,获取最后一天日期,[P
- 获取上一个月第一天的日期,获取第一天日期,[Python]代
- 用python3抓取中文网页,python3中文网页,用python3抓取中文
- 嵌套的dict按对象方式操作,嵌套dict对象,[Python]代码c
评论关闭