v04 time format update
This commit is contained in:
parent
ff413c0d8f
commit
b1db632027
|
@ -14,6 +14,8 @@ from utils.frame_opt import frame_opt
|
|||
from utils.log import is_logSuffix, log_management
|
||||
from utils.args_yaml import argsYaml
|
||||
from utils.compress import webcam_compress, is_compressFile
|
||||
from utils.time_format import time_format
|
||||
|
||||
|
||||
ROOT_PATH = sys.path[0] # 项目根目录
|
||||
OWS_VERSION = 'OpenCV Webcam Script v0.4' # 版本号
|
||||
|
@ -189,7 +191,8 @@ def webcam_opencv(device_index="0",
|
|||
print(f'程序结束!')
|
||||
e_time = time.time() # 终止时间
|
||||
total_time = e_time - s_time # 程序用时
|
||||
outTimeMsg = f'用时:{total_time/time_list[0]:.3f}秒, {total_time/time_list[1]:.3f}分, {total_time/time_list[2]:.3f}小时'
|
||||
# outTimeMsg = f'用时:{total_time/time_list[0]:.3f}秒, {total_time/time_list[1]:.3f}分, {total_time/time_list[2]:.3f}小时'
|
||||
outTimeMsg = f'用时:{time_format(total_time)}'
|
||||
print(outTimeMsg)
|
||||
log_management(f'{outTimeMsg}\n', logName, logMode) # 记录用时
|
||||
|
||||
|
|
|
@ -55,4 +55,3 @@ def webcam_compress(compressStyle, is_autoCompressName, compressName, preCompres
|
|||
compress_endTime = time.time() # 压缩结束时间
|
||||
compress_totalTime = compress_endTime - compress_startTime
|
||||
print(f'文件压缩成功!用时:{time_format(compress_totalTime)},已保存在:{compressName}')
|
||||
# print(f'文件压缩成功!用时:{compress_totalTime:.3f}秒,已保存在:{compressName}')
|
||||
|
|
|
@ -20,19 +20,27 @@ def time_format(preTime):
|
|||
|
||||
if (0 < s < 1):
|
||||
time_str = f'{s:.3f}秒'
|
||||
# print(time_str)
|
||||
return time_str
|
||||
elif (h == 0 and m == 0 and s >= 1):
|
||||
time_str = f'{s}秒'
|
||||
time_str = f'{s:.3f}秒'
|
||||
# print(time_str)
|
||||
return time_str
|
||||
elif (h == 0 and m > 0):
|
||||
time_str = f'{m}分{s}秒'
|
||||
m = int(m)
|
||||
time_str = f'{m}分{s:.3f}秒'
|
||||
# print(time_str)
|
||||
return time_str
|
||||
elif (h > 0):
|
||||
if (h >= 24):
|
||||
h = int(h / 24)
|
||||
time_str = f'{h}天{m}分{s}秒'
|
||||
m = int(m)
|
||||
time_str = f'{h}天{m}分{s:.3f}秒'
|
||||
else:
|
||||
time_str = f'{h}时{m}分{s}秒'
|
||||
h = int(h)
|
||||
m = int(m)
|
||||
time_str = f'{h}时{m}分{s:.3f}秒'
|
||||
# print(time_str)
|
||||
return time_str
|
||||
else:
|
||||
print(f'时间格式化失败!程序结束!')
|
||||
|
@ -42,7 +50,7 @@ def time_format(preTime):
|
|||
if __name__ == '__main__':
|
||||
|
||||
time_format(0.52362)
|
||||
time_format(50)
|
||||
time_format(90)
|
||||
time_format(5000)
|
||||
time_format(3600*24 + 1000)
|
||||
time_format(50.52362)
|
||||
time_format(90.52362)
|
||||
time_format(5000.52362)
|
||||
time_format(3600*24 + 1000.52362)
|
||||
|
|
Loading…
Reference in New Issue