python 解压 解缩文件
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import zipfile
import os
def unZip():
file_name = "./dist.zip"
file_zip = zipfile.ZipFile(file_name, 'r')
for file in file_zip.namelist():
file_zip.extract(file, r'.')
file_zip.close()
# os.remove(file_name)
def zip():
f = zipfile.ZipFile("./dist.zip", 'w', zipfile.ZIP_DEFLATED)
file_list = os.listdir(r'./dist')
for file_name in file_list:
if (not file_name.endswith(".zip")):
__itemFileName = "./dist/elib/" + file_name
f.write(__itemFileName,file_name)
os.remove(__itemFileName)
f.close()
if __name__ == '__main__':
unZip()
# zip()
本文标题:python 解压 解缩文件
本文链接:https://www.haomeiwen.com/subject/jzhbnhtx.html
网友评论