<legend id='6xlYX'><style id='6xlYX'><dir id='6xlYX'><q id='6xlYX'></q></dir></style></legend>
  • <tfoot id='6xlYX'></tfoot>

  • <i id='6xlYX'><tr id='6xlYX'><dt id='6xlYX'><q id='6xlYX'><span id='6xlYX'><b id='6xlYX'><form id='6xlYX'><ins id='6xlYX'></ins><ul id='6xlYX'></ul><sub id='6xlYX'></sub></form><legend id='6xlYX'></legend><bdo id='6xlYX'><pre id='6xlYX'><center id='6xlYX'></center></pre></bdo></b><th id='6xlYX'></th></span></q></dt></tr></i><div id='6xlYX'><tfoot id='6xlYX'></tfoot><dl id='6xlYX'><fieldset id='6xlYX'></fieldset></dl></div>

        <bdo id='6xlYX'></bdo><ul id='6xlYX'></ul>

        <small id='6xlYX'></small><noframes id='6xlYX'>

      1. Python pytz 时区函数返回一个相差 9 分钟的时区

        时间:2023-07-03
          <tbody id='wRDgy'></tbody>
      2. <legend id='wRDgy'><style id='wRDgy'><dir id='wRDgy'><q id='wRDgy'></q></dir></style></legend>

        <small id='wRDgy'></small><noframes id='wRDgy'>

          <i id='wRDgy'><tr id='wRDgy'><dt id='wRDgy'><q id='wRDgy'><span id='wRDgy'><b id='wRDgy'><form id='wRDgy'><ins id='wRDgy'></ins><ul id='wRDgy'></ul><sub id='wRDgy'></sub></form><legend id='wRDgy'></legend><bdo id='wRDgy'><pre id='wRDgy'><center id='wRDgy'></center></pre></bdo></b><th id='wRDgy'></th></span></q></dt></tr></i><div id='wRDgy'><tfoot id='wRDgy'></tfoot><dl id='wRDgy'><fieldset id='wRDgy'></fieldset></dl></div>

          • <tfoot id='wRDgy'></tfoot>
                <bdo id='wRDgy'></bdo><ul id='wRDgy'></ul>
                  本文介绍了Python pytz 时区函数返回一个相差 9 分钟的时区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  出于某种我还没有弄清楚的原因,从以下代码中:

                  For some reason which I haven't been able to figure out yet, from the the following code:

                  >>> from pytz import timezone
                  >>> timezone('America/Chicago')
                  

                  我明白了:

                  <DstTzInfo 'America/Chicago' LMT-1 day, 18:09:00 STD>
                  

                  什么时候,我想,我应该得到:

                  When, I assume, I should get:

                  <DstTzInfo 'America/Chicago' LMT-1 day, 18:00:00 STD>
                  

                  ...因为我不认为我的时区与 UTC 相差 6 小时 9 分钟.

                  ...since I don't think that my timezone is 6 hours and 9 minutes away from UTC.

                  我查看了 pytz 的源代码,但我承认我还没有完全弄清楚出了什么问题.

                  I have looked at the source code for pytz but I will admit that I haven't exactly been able to figure out what is going wrong.

                  我已将其他值传递给 timezone() 函数,它返回的值似乎是正确的.但由于某种原因,与我的时区相关的信息不正确.

                  I have passed other values to the timezone() function, and the values it returns appear to be correct. For some reason though, the information relevant to my timezone is not correct.

                  最后,我旁边立方体中的同事确认该函数在他的机器上返回了正确的时区信息.

                  Finally, my co-worker in the cube next to me has confirmed that the function returns the correct timezone info on his machine.

                  有人知道为什么我的时区('America/Chicago')会延迟 9 分钟吗?我正在运行使用 pip 安装的 pytz 版本 2015.7.谢谢!

                  Does anyone have any idea why my timezone ('America/Chicago') would be off by 9 minutes? I am running version 2015.7 of pytz installed using pip. Thank you!

                  推荐答案

                  除非您的本地时区有固定的 UTC 偏移量,否则在不提供具体日期/时间的情况下谈论其具体值是没有意义的.

                  Unless your local timezone has a fixed UTC offset then it is pointless to talk about its specific value without providing a specific date/time.

                  如果您提供时间,例如当前时间,那么您将看到 pytz 产生预期的 UTC 偏移量:

                  If you provide the time e.g., the current time then you'll see that pytz produces the expected UTC offset:

                  >>> from datetime import datetime
                  >>> import pytz
                  >>> datetime.now(pytz.timezone('America/Chicago')).strftime('%Z%z')
                  'CST-0600'
                  

                  • 使用pytz的日期时间时区转换
                  • pytz 本地化与日期时间替换

                  如果您不提供特定的日期/时间,则 pytz 可能会从给定时区的可用 utc 偏移量集中返回任意 utc 偏移量.最近的 pytz 版本返回对应于最早时间(通常为 LMT)的 utc 偏移量,但您不应依赖它.您和您的朋友可能使用不同的 pytz 版本,这可能会解释结果的差异.

                  If you don't provide a specific date/time then pytz may return an arbitrary utc offset from the set of available utc offsets for the given timezone. The recent pytz versions return utc offsets that correspond to the earliest time (LMT as a rule) but you should not rely on it. You and your friend may use different pytz versions that may explain the difference in results.

                  这篇关于Python pytz 时区函数返回一个相差 9 分钟的时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Python在正确的时区获取当前时间 下一篇:django 1.4 如何从客户端自动获取用户的时区

                  相关文章

                1. <legend id='um2hX'><style id='um2hX'><dir id='um2hX'><q id='um2hX'></q></dir></style></legend>

                  <small id='um2hX'></small><noframes id='um2hX'>

                  <i id='um2hX'><tr id='um2hX'><dt id='um2hX'><q id='um2hX'><span id='um2hX'><b id='um2hX'><form id='um2hX'><ins id='um2hX'></ins><ul id='um2hX'></ul><sub id='um2hX'></sub></form><legend id='um2hX'></legend><bdo id='um2hX'><pre id='um2hX'><center id='um2hX'></center></pre></bdo></b><th id='um2hX'></th></span></q></dt></tr></i><div id='um2hX'><tfoot id='um2hX'></tfoot><dl id='um2hX'><fieldset id='um2hX'></fieldset></dl></div>
                    • <bdo id='um2hX'></bdo><ul id='um2hX'></ul>
                  1. <tfoot id='um2hX'></tfoot>