def to_timestamp(dt_str, tz_str): today = datetime.strptime(dt_str, '%Y-%m-%d %H:%M:%S')
#当前时间 print(today) tz_num = re.match(r'UTC([\+\-]\d{0,2}):00', tz_str).group(1) tz = timezone(timedelta(hours = int(tz_num))) #当前时区 print(tz) #当前时间戳 curr_ts = today.replace(tzinfo = tz) print(curr_ts.timestamp()) return curr_ts.timestamp()
Sign in to make a reply
GOGOGO-枼子
def to_timestamp(dt_str, tz_str): today = datetime.strptime(dt_str, '%Y-%m-%d %H:%M:%S')