我试图用以下python代码找到两个时间字符串之间的区别。
print('time base one {}'.format(time_base_day_one))
s1 = '24:00:00'
s2 = time_base_day_one
FMT = '%HH:%MM:%SS'
print('type of time_base_day_one {} type of s1 {}'.format(type(time_base_day_one),type(s1)))
time_offset_day_two = datetime.strptime(s2, FMT) - datetime.strptime(s1, FMT)
我收到以下错误。
ValueError: time data '11:00:19' does not match format '%HH:%MM:%SS'
答案 0 :(得分:2)
格式FMT
应为'%H:%M:%S'
。以下是strftime/strptime
https://docs.python.org/3.4/library/datetime.html#strftime-and-strptime-behavior