简体   繁体   English

ValueError:时间数据'0000-00-00 00:00:00'与格式'%Y-%m-%d%H:%M:%S'不匹配

[英]ValueError: time data '0000-00-00 00:00:00' does not match format '%Y-%m-%d %H:%M:%S'

I am trying to convert my WordPress site to a static site generator using the program exitwp . 我正在尝试使用程序exitwp将WordPress网站转换为静态网站生成器。 But during the conversion process, I always get the following error message: 但是在转换过程中,我总是收到以下错误消息:

Traceback (most recent call last):
  File "exitwp.py", line 374, in <module>
    write_jekyll(data, target_format)
  File "exitwp.py", line 296, in write_jekyll
     i['date'], '%Y-%m-%d %H:%M:%S').replace(tzinfo=UTC()),
   File "/Users/xxxxx/.pyenv/versions/2.7.10/lib/python2.7/_strptime.py", line 325, in _strptime
(data_string, format))
ValueError: time data '0000-00-00 00:00:00' does not match format '%Y-%m-%d %H:%M:%S'

I am not a Python programmer but I looked up what the time data format means and it seems to me that '0000-00-00 00:00:00' DOES MATCH the format '%Y-%m-%d %H:%M:%S'. 我不是Python程序员,但是我查询了时间数据格式的含义,在我看来'0000-00-00 00:00:00'确实匹配了格式'%Y-%m-%d%H: %女士'。

Any idea what is wrong? 知道有什么问题吗? Help would be very appreciated! 帮助将不胜感激!

%Y matches years in the range 0001 through to 9999 , see the table in the module documentation : %Y匹配从00019999年份,请参见模块文档中

%Y
Year with century as a decimal number. 以世纪作为十进制数字的年份。
0001, 0002, …, 2013, 2014, …, 9998, 9999 0001,0002,…,2013,2014,…,9998,9999

Your year 0000 falls outside of that range. 您的年份0000不在该范围内。

The same issue applies to %m and %d (the acceptable ranges are 01 through to 12 , and 01 through to 31 , respectively). 相同的问题适用于%m%d (可接受的范围分别是0112 ,以及0131 )。

That's because datetime.datetime() objects have the same range for their attribute values, there is no datetime.datetime(0, 0, 0, 0, 0) object. 这是因为datetime.datetime()对象的属性值具有相同的范围,所以没有datetime.datetime(0, 0, 0, 0, 0)对象。 datetime.datetime.min is set to datetime.datetime(1, 1, 1, 0, 0) (so 0001-01-01 00:00:00 ). datetime.datetime.min设置为datetime.datetime(1, 1, 1, 0, 0) 0001-01-01 00:00:00 datetime.datetime(1, 1, 1, 0, 0) (所以0001-01-01 00:00:00 )。

Presumably 0000-00-00 00:00:00 means 'no date available'; 大概0000-00-00 00:00:00表示“无日期可用”; you'll have to alter the input to replace those dates, or handle that value to replace it with something else (perhaps None would be acceptable?) 您将不得不更改输入以替换那些日期,或处理该值以将其替换为其他值(也许None可以接受吗?)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ValueError: 时间数据 &#39;2013/05/24 07:00:00&#39; 与格式 &#39;%Y-%m-%d %H:%M:%S&#39; 不匹配 - ValueError: time data '2013/05/24 07:00:00' does not match format '%Y-%m-%d %H:%M:%S' twint 发布时间数据“2020–04–29 00:00:00”与格式“%Y-%m-%d %H:%M:%S”不匹配 - twint issue time data '2020–04–29 00:00:00' does not match format '%Y-%m-%d %H:%M:%S' Python 时间数据 &#39;2008-01-24T00:00:00:000&#39; 与格式 &#39;%Y-%m-%d %H:%M :%S:%f&#39; 不匹配 - Python time data '2008-01-24T00:00:00:000' does not match format '%Y-%m-%d %H:%M :%S:%f' Python/Odoo:ValueError:时间数据“%Y-%m-%d”与格式“2020-10-09 00:00:0)”不匹配 - Python/Odoo: ValueError: time data '%Y-%m-%d' does not match format '2020-10-09 00:00:0)' 我有一个错误提示 ValueError: time data '31 days, 0:00:00' does not match format '%Y-%m-%d' - I have an error that says ValueError: time data '31 days, 0:00:00' does not match format '%Y-%m-%d' ValueError: 时间数据 &#39;2020-01-31T15:16:21+00:00&#39; 与格式 &#39;%Y-%m-%dT%H:%M:%S%z&#39; 不匹配 - ValueError: time data '2020-01-31T15:16:21+00:00' does not match format '%Y-%m-%dT%H:%M:%S%z' 时间数据“2021-03-31 23:30:00”与格式“%Y-%m-%d %H:%M:S”不匹配 - time data '2021-03-31 23:30:00' does not match format '%Y-%m-%d %H:%M:S' ValueError:时间数据&#39;2017-04-20 10:00:00-04:00&#39;与格式&#39;%Y-%b-%d%H:%M:%S-%Z&#39;不匹配 - ValueError: time data '2017-04-20 10:00:00-04:00' does not match format '%Y-%b-%d %H:%M:%S-%Z' ValueError:时间数据&#39;2012-07-19 08:24:00&#39;与格式&#39;%Y-%m-%d H:M:S&#39;不匹配 - ValueError: time data '2012-07-19 08:24:00' does not match format '%Y-%m-%d H:M:S' ValueError: 时间数据 &#39;2021-11-05 10:13:46+11:00&#39; 与格式 &#39;%y-%m-%d %H:%M:%S%z&#39; 不匹配 - ValueError: time data '2021-11-05 10:13:46+11:00' does not match format '%y-%m-%d %H:%M:%S%z'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM