Python 将时间增量转换为分钟
我用变量current time和end_程序计算剩余的分钟数Python 将时间增量转换为分钟,python,python-2.7,Python,Python 2.7,我用变量current time和end_程序计算剩余的分钟数 current_time = datetime.timedelta(hours = get_24_hours, minutes = get_24_minutes) end_program = datetime.timedelta(hours = int(program_hours), minutes = int(program_minutes)) current_program = end_program - current_tim
current_time = datetime.timedelta(hours = get_24_hours, minutes = get_24_minutes)
end_program = datetime.timedelta(hours = int(program_hours), minutes = int(program_minutes))
current_program = end_program - current_time
输出:
1:30:00
2:00:00
0:45:00
0:45:00
0:15:00
0:15:00
0:35:00
我想将时间增量转换为分钟:
90
120
45
45
15
15
35
print int(current_program.total_seconds() / 60)
你可以看到时间差0:15:00
,意思是15分钟,所以我想把它转换成15
,对于0:35:00
作为35分钟,我想把它转换成35
,对于0:45:00
作为45分钟,我想把它转换成45
,但是对于2:00:00
作为2小时,我想将其转换为120
作为120分钟。对于1:30:00
作为1小时30分钟,我想将其转换为90
分钟
如何将时间增量转换为分钟?您可以将秒转换为分钟:
90
120
45
45
15
15
35
print int(current_program.total_seconds() / 60)
看:
看看: