def to_timestamp(dt_str, tz_str): h_groups = re.match(r'^UTC([+-]{1}\d{1,2}):0{2}$',tz_str) # 取出字符串 -09 or +8 hour = h_groups.group(1) # 格式化时区 tz_utc = timezone(timedelta(hours=int(hour))) # 执行返回 timestamp 时间 return datetime.strptime(dt_str,'%Y-%m-%d %H:%M:%S').replace(tzinfo=tz_utc).timestamp()
Sign in to make a reply
黑色镜框BlacKiller
老师出的题挺好,不难还能覆盖知识点