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()
网友评论