def to_timestamp(dt_str, tz_str): # 提取时区 timeNum = re.match(r'.*?([\-\+\d]+)',tz_str).group(1) num = timeNum.replace("0","").replace("+","") # 新建时区 tz_utc = timezone(timedelta(hours=int(num))) # string转换datetime cday = datetime.strptime(dt_str,'%Y-%m-%d %H:%M:%S') # 转换时区 dt = cday.replace(tzinfo=tz_utc) # 返回毫秒值 return dt.timestamp()
Sign in to make a reply
Chris_Gardner_II