Discuss / Python / 作业

作业

Topic source
def to_timestamp(dt_str, tz_str):
    the_time = datetime.strptime(dt_str, '%Y-%m-%d %H:%M:%S')
    n = re.findall('UTC(.*):\d\d',tz_str)[0]
    n = int(n)
    tz_utc_n = timezone(timedelta(hours=n))
    dt = the_time.replace(tzinfo=tz_utc_n)
    return dt.timestamp()

  • 1

Reply