>>> import pytz
>>> tz = pytz.timezone(\'America/Chicago\')
>>> dt_naive = datetime(year=2017, month=6, day=6)
>>> dt_aware = tz.
The key that determines the timezone from pytz
is the string you passed to create the object: 'America/Chicago'
. That key is available through the .zone
attribute.
>>> tz = pytz.timezone('America/Chicago')
>>> dt_naive = datetime(year=2017, month=6, day=6)
>>> dt_aware = tz.localize(dt_naive)
>>> dt_aware.tzinfo == tz
False
>>> tz.zone
'America/Chicago'
>>> dt_aware.tzinfo.zone == tz.zone
True