Discuss / Python / 交作业,为什么你们都写正则。。

交作业,为什么你们都写正则。。

Topic source
def to_timestamp(dt_str, tz_str):
    dt = datetime.strptime(dt_str, '%Y-%m-%d %H:%M:%S')
    tz_hour = int(tz_str[3:].split(':')[0])
    tz_utc = timezone(timedelta(hours = tz_hour))

    return dt.replace(tzinfo = tz_utc).timestamp()

  • 1

Reply