【问题标题】:Python 3.6 datetime.fromtimestamp throws error when given 0Python 3.6 datetime.fromtimestamp 在给定 0 时抛出错误
【发布时间】:2017-07-13 18:43:32
【问题描述】:

在 Python 3.5.2 中这有效:

datetime.datetime.fromtimestamp(0)
returns -> datetime.datetime(1970, 1, 1, 1, 0)

然而,在 Python 3.6 中,我得到了

datetime.datetime.fromtimestamp(0)
-> OSError: [Errno 22] Invalid argument

我在文档中找不到对函数的任何更改。我很好奇为什么这会破坏我的脚本以及我在哪里可以找到原因。

有人能解释一下吗?

【问题讨论】:

  • 无法使用 Python 3.6.0 @ Linux 重现您是从 repos 还是以其他方式安装 Python 3.6?
  • 刚刚检查了 python 3.6.0 并在 Windows 10 上适用于 3.5.1 和 3.4.3 时遇到相同的错误
  • Python 3.6.1 中存在错误

标签: python python-3.x datetime


【解决方案1】:

这是仅在 Windows 上的 Python 3.6.0 中引入的错误。
详情:https://bugs.python.org/issue29097

补丁正在开发中,可能很快就会修复。

【讨论】:

  • 我很惊讶这没有出现在 Google 上。谢谢!
  • 你找到答案了吗?修好了吗?
猜你喜欢
  • 2019-09-29
  • 1970-01-01
  • 1970-01-01
  • 2020-08-07
  • 2017-10-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-06-06
相关资源
最近更新 更多