To get a naive datetime object that represents time in UTC from “seconds since the epoch” timestamp:
from datetime import datetime
utc_dt = datetime.utcfromtimestamp(ts)
If you want to get an aware datetime object for UTC timezone:
import pytz
aware_utc_dt = utc_dt.replace(tzinfo=pytz.utc)
To convert it to some other timezone:
tz = pytz.timezone('America/Montreal')
dt = aware_utc_dt.astimezone(tz)
To convert the timestamp to an aware datetime object in the given timezone directly:
dt = datetime.fromtimestamp(ts, tz)