如何获得小时:分钟 [英] How get hours:minutes

查看:155
本文介绍了如何获得小时:分钟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里有一个脚本(不是我自己的脚本),它可以计算我的satreceiver中的电影长度。它显示的长度在分钟:秒



我希望在小时:分钟



我必须做什么改变?

这是相关脚本的和平:

  if len> 0:
len =%d:%02d%(len / 60,len%60)
else:
len =

res = [无]

我已经把时间除以3600而不是60,但是不能得到分钟...
$ b $ p


你可以使用timedelta $ date
$ b

 从datetime导入timedelta 
str( timedelta(minutes = 100))[: - 3]
#1:40


I have a script here (not my own) which calculates the length of a movie in my satreceiver. It displays the length in minutes:seconds

I want to have that in hours:minutes

What changes do I have to make?

This is the peace of script concerned:

if len > 0:
    len = "%d:%02d" % (len / 60, len % 60)
else:
    len = ""

res = [ None ]

I already got the hours by dividing by 3600 instead of 60 but can't get the minutes...

Thanks in advance

Peter

解决方案

You can use timedelta

from datetime import timedelta
str(timedelta(minutes=100))[:-3]
# "1:40"

这篇关于如何获得小时:分钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆