ValueError: 时间数据“In 00 days 23:07:56"与格式“In %d days %H:%M:%S"不匹配 [英] ValueError: time data 'In 00 days 23:07:56' does not match format 'In %d days %H:%M:%S'
本文介绍了ValueError: 时间数据“In 00 days 23:07:56"与格式“In %d days %H:%M:%S"不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用时间库解析我的日期字符串.但我在解析时出错.
I am trying to parse my date string with time library. But i have an error in parsing.
# Example is 'In 0 days 23:07:56'
client['license_time_start'] = time.strptime('In 0 days 23:07:56', 'In %d days %H:%M:%S')
ValueError: 时间数据In 00 days 23:07:56"与格式In %d days %H:%M:%S"不匹配
ValueError: time data 'In 00 days 23:07:56' does not match format 'In %d days %H:%M:%S'
推荐答案
该错误是因为日期不能为 0
.它必须是一个正整数.
The error is because date can't be 0
. It has to be an positive integer.
因此,这会产生一个错误:-
Therefore, this produces an error:-
time.strptime('In 0 days 23:07:56', 'In %d days %H:%M:%S')
# ValueError: time data 'In 0 days 23:07:56' does not match format 'In %d days %H:%M:%S'
这不会:-
time.strptime('In 01 days 23:07:56', 'In %d days %H:%M:%S')
# time.struct_time(tm_year=1900, tm_mon=1, tm_mday=1, tm_hour=23, tm_min=7, tm_sec=56, tm_wday=0, tm_yday=1, tm_isdst=-1)
这篇关于ValueError: 时间数据“In 00 days 23:07:56"与格式“In %d days %H:%M:%S"不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文