Discuss / Python / 我的代码

我的代码

Topic source

def to_timestamp(dt_str, tz_str): dt = datetime.strptime(dt_str, '%Y-%m-%d %H:%M:%S') match_dt = re.match(r'[\w]+([+-]\d+):\d+', tz_str).group(1) tz_utc = timezone(timedelta(hours=int(match_dt))) dt = dt.replace(tzinfo=tz_utc) return dt.timestamp()


  • 1

Reply