v04 update 03

This commit is contained in:
13339479676 2022-01-20 18:24:04 +08:00
parent 5788a760bc
commit 9afdeb7e09
2 changed files with 31 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import sys
import os
from tqdm import tqdm
import time
from utils.time_format import time_format
ROOT_PATH = sys.path[0] # 项目根目录
COMPRESS_SUFFIX = ['zip', 'tar'] # 压缩文件格式
@ -53,4 +54,5 @@ def webcam_compress(compressStyle, is_autoCompressName, compressName, preCompres
compress_file.close()
compress_endTime = time.time() # 压缩结束时间
compress_totalTime = compress_endTime - compress_startTime
print(f'文件压缩成功!用时:{compress_totalTime}s已保存在{compressName}')
# print(f'文件压缩成功!用时:{time_format(compress_totalTime)},已保存在:{compressName}')
print(f'文件压缩成功!用时:{round(compress_totalTime, 3)}秒,已保存在:{compressName}')

28
utils/time_format.py Normal file
View File

@ -0,0 +1,28 @@
# 时间格式化
# 创建人:曾逸夫
# 创建时间2022-01-19
import sys
def is_time(preTime):
if (preTime <= 0):
print(f'时间格式不正确!程序结束!')
sys.exit()
def time_format(preTime):
is_time(preTime)
m, s = divmod(preTime, 60)
h, m = divmod(m, 60)
time_list = [s, m, h]
time_list = [round(i, 3) for i in time_list]
# print(f'{h}小时{m}分{s}秒')
return f'{time_list[2]}小时{time_list[1]}{time_list[0]}'
if __name__ == '__main__':
# time_test = 3600*24 + 1000
time_test = 0.52312
# time_test = 5000
time_format(time_test)