Discuss / Python / 交作业——类方法和实例方法需要分清

交作业——类方法和实例方法需要分清

Topic source
def to_timestamp(dt_str, tz_str):
    dt = datetime.strptime(dt_str, '%Y-%m-%d %H:%M:%S')
    tz = timezone(timedelta(hours = int(tz_str[3:tz_str.find(':')])))
    dt1 = dt.replace(tzinfo = tz)
    return dt1.timestamp()

  • 1

Reply