def to_timestamp(dt_str, tz_str):
# 时区转换 tz_tmp = tz_str.strip('UTC').split(':')[0] tz_utc = timezone(timedelta(hours = int(tz_tmp))) # 获取时间 dt_local = datetime.strptime(dt_str, '%Y-%m-%d %H:%M:%S') dt = dt_local.replace(tzinfo=tz_utc) # 转为timestamp result = dt.timestamp() return result
你那个获取时区那个有点问题吧。
Sign in to make a reply
太虚山寺
def to_timestamp(dt_str, tz_str):