python压缩和读取.tar.bz2格式的压缩包,python.tar.bz2,#压缩文件夹为 .tar
文章由Byrx.net分享于2019-03-23 11:03:45
python压缩和读取.tar.bz2格式的压缩包,python.tar.bz2,#压缩文件夹为 .tar
#压缩文件夹为 .tar.bz2import tarfileimport bz2archive = tarfile.open('myarchive.tar.bz2','w:bz2')archive.debug = 1 # Display the files beeing compressed.archive.add(r'd:\myfiles') # d:\myfiles contains the files to compressarchive.close()#解压一个.tar.bz2import tarfileimport bz2archive = tarfile.open('myarchive.tar.bz2','r:bz2')archive.debug = 1 # Display the files beeing decompressed.for tarinfo in archive: archive.extract(tarinfo, r'd:\mydirectory') # d:\mydirectory is where I want to uncompress the files.archive.close()
相关内容
- webpy输出json例子代码,webpy输出json,webpy中可以方便的输
- python的反射:动态获得模块,类,python模块,python的反射
- python使用urllib2抓取网页时的错误处理,pythonurllib2,try
- python计算代码执行时间,python计算代码,import times
- python使用xmlproc验证xml格式是否符合DTD定义,xmlprocdtd,
- python线程池实现,python线程池,python原生包中没有
- python的SIGIO handler,sigiohandler,On Linux, us
- python写的一个骰子程序,python写骰子程序,import rando
- python中RGB和HSL的相互转换,pythonrgbhsl,def HSL_to_R
- Python从int继承实现枚举,pythonint枚举,枚举可以给数字一
评论关闭