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

标签 python python-dateutil

如果我运行以下命令:

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.

关于python - 为什么调用 dateutil.parser.parse 表明 11 月是 12 月?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27230503/

相关文章:

python-2.7 - 类型错误 : can't subtract offset-naive and offset-aware datetimes

python - 在python中将带有时区缩写的非UTC时间字符串转换为UTC时间,同时考虑夏令时

python - 推断日期格式与传递解析器

python - 在 C++ : variable is never initialized 中使用 cython cdef 公共(public)变量

python - 无法在 ubuntu 上正确 pip install tsne?

python - 使用 boto3 挂载 EBS 卷

python - 使用 Python 和 pyparsing 解析 Visual Basic 函数的参数列表

python - 使用正则表达式迭代从制表符分隔表创建的 Python 字典

python - 如何检查 relativedelta 对象是否为负数

python - 月份范围计算未返回预期结果