【问题标题】:Python pytz: timezone("xxx") gives "unpack requires a string argument of length 44"Python pytz:timezone("xxx") 给出“解包需要长度为 44 的字符串参数”
【发布时间】:2013-03-10 16:52:16
【问题描述】:

当我尝试使用 pytz 创建一些时区时,出现错误“struct.error: unpack requires a string argument of length 44”。对于其他人来说,它工作正常。

前两个效果很好。后两个给出错误:

import pytz
from pytz import timezone

tz_dk = timezone("Europe/Copenhagen") 
tz_cn =  timezone("Atlantic/Canary")

tz_us = timezone("US/Eastern")
tx_lo = timezone("Europe/London")

我打印了所有时区的列表,所有四个都在那里。

for tz in pytz.all_timezones:
    print tz

【问题讨论】:

    标签: python pytz


    【解决方案1】:

    我重新安装了 pytz,现在它可以工作了。很奇怪。

    测试过

    for value in pytz.all_timezones:
         try:
            t =  timezone(value)
        except:
            print "FAIL", value
    

    没有失败。

    【讨论】:

      猜你喜欢
      • 2012-12-08
      • 1970-01-01
      • 1970-01-01
      • 2015-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-08
      • 1970-01-01
      相关资源
      最近更新 更多