Django將秒轉(zhuǎn)換為xx天xx時(shí)xx分,具體代碼如下所示:
蚌埠ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場(chǎng)景,ssl證書未來市場(chǎng)廣闊!成為創(chuàng)新互聯(lián)的ssl證書銷售渠道,可以享受市場(chǎng)價(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))