Python pytz: timezone(“xxx”) gives “unpack requires a string argument of length 44”

孤街浪徒 提交于 2020-01-05 07:32:07

问题


I am getting an error "struct.error: unpack requires a string argument of length 44" when I try to create some of the timezones using pytz. For others it works fine.

The first two work great. The second two give the error:

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")

I printed out a list of all the time zones and all four are there.

for tz in pytz.all_timezones:
    print tz

回答1:


I reinstalled pytz and now it works. Weird.

Tested it with

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

No fails.



来源:https://stackoverflow.com/questions/15324833/python-pytz-timezonexxx-gives-unpack-requires-a-string-argument-of-length

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!