Discuss / Python / 作业

作业

Topic source

Champhy_Who

#1 Created at ... [Delete] [Delete and Lock User]
import re
from datetime import datetime, timezone, timedelta

def to_timestamp(dt_str, tz_str):
    h=8-int(re.match(r'UTC(...?):00',tz_str).group(1))
    usert=datetime.strptime(dt_str,'%Y-%m-%d %H:%M:%S')
    bt=usert+timedelta(hours=h)
    t=bt.timestamp()       
    return t

Champhy_Who

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

不好,还是定义所在时区好。


  • 1

Reply