Discuss / Python / 交卷

交卷

Topic source

GOGOGO-枼子

#1 Created at ... [Delete] [Delete and Lock User]

def to_timestamp(dt_str, tz_str): today = datetime.strptime(dt_str, '%Y-%m-%d %H:%M:%S')

#当前时间
print(today)
tz_num = re.match(r'UTC([\+\-]\d{0,2}):00', tz_str).group(1)
tz = timezone(timedelta(hours = int(tz_num)))
#当前时区
print(tz)

#当前时间戳
curr_ts = today.replace(tzinfo = tz)
print(curr_ts.timestamp())

return curr_ts.timestamp()

  • 1

Reply