Discuss / Python / 交作业

交作业

Topic source

黄展奇

#1 Created at ... [Delete] [Delete and Lock User]
def to_timestamp(dt_str, tz_str):
    dt = datetime.strptime(dt_str, '%Y-%m-%d %H:%M:%S')
    tz_str = re.sub(r'[a-zA-Z]|:.*', '', tz_str)
    tz = timezone(timedelta(hours=int(tz_str)))
    dt = dt.replace(tzinfo=tz)
    return dt.timestamp()

  • 1

Reply