Discuss / Python / 交作业

交作业

Topic source

#1 Created at ... [Delete] [Delete and Lock User]
import refrom datetime import datetime, timezone, timedeltadef to_timestamp(dt_str, tz_str):    hours = int(re.match(r'UTC([+\-0-9]+):\d+',tz_str).group(1))    dt = datetime.strptime(dt_str, '%Y-%m-%d %H:%M:%S')    return dt.timestamp() + (8 - hours) * 60 * 60

  • 1

Reply