Discuss / Python / 晚安兄弟们

晚安兄弟们

Topic source

def to_timestamp(dt_str, tz_str): cday=datetime.strptime(dt_str,'%Y-%m-%d %H:%M:%S') tz_num=int(re.match('UTC(+\d+|-\d+):\d+',tz_str).group(1)) tz=timezone(timedelta(hours=tz_num)) ts=cday.replace(tzinfo=tz) return ts.timestamp()


  • 1

Reply