v04 update 03
This commit is contained in:
parent
5788a760bc
commit
9afdeb7e09
|
@ -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}')
|
||||
|
|
|
@ -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)
|
Loading…
Reference in New Issue