Discuss / Python / 为什么你们的正则写的那么麻烦呢

为什么你们的正则写的那么麻烦呢

Topic source

def to_timestamp(dt_str, tz_str): dt = datetime.strptime(dt_str, "%Y-%m-%d %H:%M:%S") tz = re.findall(r"C(.+):", tz_str)[0] tz_utc = timezone(timedelta(hours=int(tz))) timestamp = dt.replace(tzinfo=tz_utc).timestamp() return timestamp


  • 1

Reply