Discuss / Python / 作业

作业

Topic source

def to_timestamp(dt_str, tz_str): dt = datetime.strptime(dt_str, '%Y-%m-%d %H:%M:%S') tz_r = re.match(r'UTC([+|-]\d+):\d{2}', tz_str) tz = timezone(timedelta(hours=int(tz_r.group(1)))) dt = dt.replace(tzinfo=tz) return dt.timestamp()


  • 1

Reply