Discuss / Python / 打卡

打卡

Topic source

def to_timestamp(dt_str, tz_str):

    utc = int(re.search(r'([\+\-]\d+)', tz_str).group(1))

    dt = datetime.strptime(dt_str, '%Y-%m-%d %H:%M:%S')

    st = dt.replace(tzinfo=timezone(timedelta(hours=utc))).timestamp()

    return st


  • 1

Reply