def to_timestamp(dt_str, tz_str):
now = datetime.strptime(dt_str, '%Y-%m-%d %H:%M:%S')
tz = int(re.match(r'.+?([+-]\d+)', tz_str).group(1))
now = now.replace(tzinfo = timezone(timedelta(hours=tz)))
return now.timestamp()
Sign in to make a reply
用户6589242306
def to_timestamp(dt_str, tz_str):
now = datetime.strptime(dt_str, '%Y-%m-%d %H:%M:%S')
tz = int(re.match(r'.+?([+-]\d+)', tz_str).group(1))
now = now.replace(tzinfo = timezone(timedelta(hours=tz)))
return now.timestamp()