python shutil&压缩&解压$zipfile

2018-06-18  本文已影响0人  小草_fdba

shutil.copyfileobj(f1,f2,length=10)
压缩
import shutil
shutil.make_archive('/tmp/hw', 'zip','../homeWork1.1',owner='may')

压缩

import zipfile
z=zipfile.ZipFile('test.zip','w')
z.write('airflow.py')
z.write('shoppingCart.txt')
z.close()

解压缩

import zipfile
z=zipfile.ZipFile('test.zip','r')
z.extractall()
z.close()

tar只打包不压缩

import tarfile
t=tarfile.open('test.tar','w')
t.add("airflow.py")
t.close()
上一篇 下一篇

猜你喜欢

热点阅读