def to_timestamp(dt_str, tz_str): tz_utc= re.match(r'^UTC(.\d+):00',tz_str).group(1) # print(type(tz_utc), tz_utc) # str ==> datetime dt_datetime = datetime.strptime(dt_str,'%Y-%m-%d %H:%M:%S') # print(dt_datetime) # 创建指定时区tz_utc(提取自tz_str) tz_utc = timezone(timedelta(hours=int(tz_utc))) # 将给定时间dt_datetime(from dt_str)强制设置为指定的时区tz_utc dt_datetime_std = dt_datetime.replace(tzinfo=tz_utc) # 返回timestamp return dt_datetime_std.timestamp()
Sign in to make a reply
me唯爱婷