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

StackOverflow https://stackoverflow.com/questions/15324833

  •  21-03-2022
  •  | 
  •  

質問

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
役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top