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')
    if len(tz_str)==8:
        tz = int(tz_str[3:5])
    else:
        tz = int(tz_str[3:6])
    #cday = cday - timedelta(hours = tz)
    return cday.replace(tzinfo=timezone(timedelta(hours=tz))).timestamp()

  • 1

Reply