在jupyterlab和python depp中运行时,带有w/ w/ o时区的时间戳不一致

发布于 2025-02-12 08:41:14 字数 1080 浏览 0 评论 0原文

我试图了解Python中时区幼稚的日期的时间戳。我想TimeZone幼稚的日期时间可能具有与UTC DateTime具有相同数字的时间戳相同的时间戳。

首先,我在jupyterlab(pycharm)中对其进行测试:

”在此处输入图像描述

它们具有相同的时间戳号码。

然后,我直接在Python解释器中对其进行测试:

”在此处输入图像描述”

发生的奇怪事情正在发生 - 时间戳现在为不同的!这次,没有时区的日期实际上是我的当地时间(澳大利亚/悉尼)。我在此处对其进行了验证:

“在此处输入图像描述”

这令人困惑。

  • 为什么Jupyterlab和Python解释器有不同的 对此行为?

刚刚意识到我的jupyter在码头容器中运行,并且容器中的时区是UTC。

(base) root@2ddb91b80e47:~# date
Sun Jul  3 06:42:44 UTC 2022
  • 什么时候应该是什么样的时间戳 为DateTime分配没有时区信息?

I'm trying to understand the timestamp of timezone naive datetime in Python. I guess the timezone naive datetime may has the same timestamp with the UTC datetime witht the same digits.

First I test it in jupyterlab (Pycharm):

enter image description here

They have the same timestamp number.

Then I test it in Python interpreter directly:

enter image description here

Strange things happening - the timestamps are now different! This time the datetime with no timezone is in fact my local time (Australia/Sydney). I verified it here:

enter image description here

This is confusing.

  • Why do the Jupyterlab and Python interpreter have different
    behaviours on this?

Just realized my jupyter is running in a docker container and the timezone in the container is UTC.

(base) root@2ddb91b80e47:~# date
Sun Jul  3 06:42:44 UTC 2022
  • What kind of timestamp should it be when
    assigning no timezone info for a datetime?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文