Django將秒轉(zhuǎn)換為xx天xx時(shí)xx分,具體代碼如下所示:
蚌埠ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)的ssl證書銷售渠道,可以享受市場價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:13518219792(備注:SSL證書合作)期待與您的合作!from django.utils.translation import ngettext_lazy as _n def humanize_seconds(secs): a_day = 86400 an_hour = 3600 a_minute = 60 timetot = '' total_secs = secs if secs > a_day: # 60sec * 60min * 24hrs days = int(secs // a_day) # timetot += "{} {}".format(int(days), _('days')) timetot += _n('%(num)s day', '%(num)s days', days) % {'num': days} secs = secs - days * a_day if secs > an_hour: hrs = int(secs // an_hour) # timetot += " {} {}".format(int(hrs), _('hours')) timetot += ' ' timetot += _n('%(num)s hour', '%(num)s hours', hrs) % {'num': hrs} secs = secs - hrs * an_hour if secs > a_minute and total_secs < a_day: mins = int(secs // a_minute) timetot += ' ' timetot += _n('%(num)s minute', '%(num)s minutes', mins) % {'num': mins} secs = secs - mins * a_minute if secs > 0 and total_secs < an_hour: secs = int(secs) timetot += ' ' timetot += _n('%(num)s second', '%(num)s seconds', secs) % {'num': secs} return timetot if __name__ == "__main__": print(humanize_seconds(360200))
網(wǎng)站欄目:詳解Django將秒轉(zhuǎn)換為xx天xx時(shí)xx分-創(chuàng)新互聯(lián)
文章分享:http://m.rwnh.cn/article40/ddoseo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供建站公司、定制網(wǎng)站、搜索引擎優(yōu)化、App開發(fā)、自適應(yīng)網(wǎng)站、全網(wǎng)營銷推廣
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容