为什么打电话给dateutil.parser.parse文件十一月是十二月吗?

2024-09-27 09:24:55 发布

您现在位置:Python中文网/ 问答频道 /正文

如果我运行以下命令:

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

我明白了:

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

为什么说是十二月而不是十一月?你知道吗


Tags: fromimport命令trueparserdatetimeparsefuzzy
1条回答
网友
1楼 · 发布于 2024-09-27 09:24:55

它无法完全解析字符串的结构。当dateutil.parser.parse缺少某个字段时,例如月份,它将用当前月份(即12月)填充该字段。你知道吗

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.

相关问题 更多 >

    热门问题