Discuss / Python / 作业 使用str.strip()

作业 使用str.strip()

Topic source

小小事界

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

def to_timestamp(dt_str, tz_str):

    hours = int(tz_str.strip('0').strip('UTC+:'))

    dt = datetime.strptime(dt_str, '%Y-%m-%d %H:%M:%S').replace(tzinfo=timezone(timedelta(hours=hours)))

    return dt.timestamp()


  • 1

Reply