Skip to main content
 首页 » 编程设计

python之为什么调用 dateutil.parser.parse 表明 11 月是 12 月

2025年05月04日13webabcd

如果我运行以下命令:

from dateutil import parser 
parser.parse("Wind10_463@Y2014_M11_D19", fuzzy=True) 

我明白了:

datetime.datetime(2014, 12, 19, 0, 0) 

为什么说十二月而不是十一月?

请您参考如下方法:

它无法完全解析字符串的结构。当 dateutil.parser.parse 缺少其中一个字段(例如月份)时,它将用当前月份(即十二月)填充。

From the docs :

default: If given, this must be a datetime instance. Any fields missing in the parsed date will be copied from > this instance. The default value is the current date, at 00:00:00am.