Discuss / Python / 作业

作业

Topic source

一度剑心

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

def to_timestamp(dt_str, tz_str):

    cday=datetime.strptime(dt_str, '%Y-%m-%d %H:%M:%S')

    m=re.match(r'UTC(.*):',tz_str)

    cday=cday.replace(tzinfo=timezone(timedelta(hours=int(m.group(1)))))

    return cday.timestamp()


  • 1

Reply