标签:时间格式 时间 class date pre 时间差 diff print 字符
1 #coding:utf8 2 import datetime 3 def time_differ(date1=‘12:55:05‘,date2=‘13:15:05‘): 4 ‘‘‘ 5 @传入是时间格式如‘12:55:05‘ 6 ‘‘‘ 7 date1=datetime.datetime.strptime(date1,"%H:%M:%S") 8 date2=datetime.datetime.strptime(date2,"%H:%M:%S") 9 if date1 < date2: 10 return date2-date1 11 else: 12 return date1-date2 13 14 date1 = ‘13:05:05‘ 15 date2 = ‘13:15:05‘ 16 differ = time_differ(date1,date2) 17 18 print differ
标签:时间格式 时间 class date pre 时间差 diff print 字符
原文地址:http://www.cnblogs.com/zsl-3/p/6172190.html