zip update
This commit is contained in:
parent
5702bbd0a1
commit
88c953cf18
|
@ -20,17 +20,20 @@ def is_zipFile(zipName):
|
|||
# zip压缩
|
||||
def webcam_zip(is_autoZipName, zipName, preZipFilePath, zipMode):
|
||||
if (is_autoZipName):
|
||||
# 自动命名
|
||||
zipNameTmp = str(preZipFilePath).split('/')[-1]
|
||||
zipName = f'{ROOT_PATH}/{zipNameTmp}.zip'
|
||||
else:
|
||||
is_zipFile(zipName)
|
||||
zip_file = zipfile.ZipFile(zipName, zipMode)
|
||||
# 手动命名
|
||||
is_zipFile(zipName) # 判断zip名称格式
|
||||
zip_file = zipfile.ZipFile(zipName, zipMode) # 实例化zipfile对象
|
||||
|
||||
# ----------压缩开始----------
|
||||
file_list = os.listdir(preZipFilePath)
|
||||
file_list = os.listdir(preZipFilePath) # 获取目录下的文件名称
|
||||
for i in range(len(file_list)):
|
||||
# 写入压缩文件
|
||||
zip_file.write(f'{preZipFilePath}/{file_list[i]}',
|
||||
compress_type=zipfile.ZIP_DEFLATED) # 压缩单个文件
|
||||
# ----------压缩结束----------
|
||||
zip_file.close()
|
||||
print(f'压缩成功!保存在{zipName}')
|
||||
print(f'压缩成功!已保存在:{zipName}')
|
||||
|
|
Loading…
Reference in New Issue