localFormat = “%Y-%m-%dT%H:%M:%S.000000000Z”
# first specify string format
localFormat = “%Y-%m-%dT%H:%M:%S.000000000Z”# construct a datetime from string
localmoment_naive = datetime.strptime('2020-09-22T01:02:03.000000000Z', localFormat)# set timezone to utc
utcomment = localmoment_naive.replace(tzinfo=pytz.utc)# convert time to expected timezone
localDatetime = utcomment.astimezone(pytz.timezone("America/Toronto"))# show it
localDatetime