v04 zip 03
This commit is contained in:
parent
d46d127178
commit
4ce6161761
|
@ -9,6 +9,7 @@ import os
|
|||
ROOT_PATH = sys.path[0] # 项目根目录
|
||||
|
||||
|
||||
# 判断zip文件名称
|
||||
def is_zipFile(zipName):
|
||||
zipNameSuffix = zipName.split('.')[-1]
|
||||
if zipNameSuffix != "zip":
|
||||
|
@ -16,15 +17,16 @@ def is_zipFile(zipName):
|
|||
sys.exit()
|
||||
|
||||
|
||||
def webcam_zip(zipName, zipFilePath):
|
||||
# zip压缩
|
||||
def webcam_zip(zipName, preZipFilePath):
|
||||
is_zipFile(zipName)
|
||||
|
||||
zip_file = zipfile.ZipFile(zipName, 'a')
|
||||
|
||||
# ----------压缩开始----------
|
||||
file_list = os.listdir(zipFilePath)
|
||||
file_list = os.listdir(preZipFilePath)
|
||||
for i in range(len(file_list)):
|
||||
zip_file.write(f'{zipFilePath}/{file_list[i]}',
|
||||
zip_file.write(f'{preZipFilePath}/{file_list[i]}',
|
||||
compress_type=zipfile.ZIP_DEFLATED) # 压缩单个文件
|
||||
# ----------压缩结束----------
|
||||
zip_file.close()
|
||||
|
|
Loading…
Reference in New Issue