各位用户为了找寻关于python简单实现计算过期时间的方法的资料费劲了很多周折。这里教程网为您整理了关于python简单实现计算过期时间的方法的相关资料,仅供查阅,以下为您介绍关于python简单实现计算过期时间的方法的详细内容

本文实例讲述了python简单实现计算过期时间的方法。分享给大家供大家参考。具体如下:

? 1 2 3 4 5 6 7 8 9 10 def time_passed(value):   now = datetime.now()   past = now - value   if past.days:     return u'%s天前' % past.days   mins = past.seconds / 60   if mins < 60:     return u'%s分钟前' % mins   hours = mins / 60   return u'%s小时前' % hours

希望本文所述对大家的Python程序设计有所帮助。