Python 压缩文件(3),python压缩文件,制成tar+gzipim
Python 压缩文件(3),python压缩文件,制成tar+gzipim
制成tar+gzip
import osimport tarfileimport gzipimport string import shutildef zipDir(src,dst): initPath = os.getcwd() #tempDST = os.path.join(os.getcwd(),dst) #tempSRC = os.path.join(os.getcwd(),src) os.chdir( src ) files = os.listdir(src) if dst.find("\\\\") != -1: temp = dst.rsplit("\\\\",1) dstname = temp[1] dstpath = temp[0] #print files tar = tarfile.open(dstname,"gz") for file in files: tar.add(file) tar.close() os.chdir( initPath ) if os.path.isfile(dst) == True: os.remove(dst) shutil.copy(os.path.join(src,dstname), dst) os.remove(os.path.join(src,dstname)) print os.getcwd()#test okif __name__ == '__main__': zipDir("D:\\\\AutoUpdate\\\\DataDist\\\\viruswall\\\\Data\\\\KSVW-VirusDB\\\\","d:\\\\AutoUpdate\\\\DataDist\\\\viruswall\\\\Data\\\\update\\\\KSVW-VirusDB.tgz")#该片段来自于http://byrx.net
相关内容
- Python 压缩文件(2),python压缩文件,加入了tar环节,但是
- Python 解析xml(dom),python解析xmldom,from xml.dom
- Python中的工厂方法 funtional的思维来做 非oop的实现,f
- Python 自动连接ssh,Python连接ssh,#!/usr/bin/p
- md5Crack_V0.1,,Python语言: md
- python.递归遍历指定的目录,python递归遍指定,Python语言
- 网易新闻小爬虫.v0.1,网易新闻爬虫.v0.1,Python语言: 网易
- Python版的农历日历Calendar,功能简单,pythoncalendar,Pyth
- 人性化的时间(比如:两分钟以前),人性化两分钟
- 筛法生成质数(素数)的生成器,质数素数,Python语言
评论关闭