Discuss / Python / 绕了个大远,把时区还转成了标准时区

绕了个大远,把时区还转成了标准时区

Topic source

bzny虫

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

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

    tzm0=re.match(r'^UTC([+-])0?(\d)', tz_str)

    tzm=tzm0.group(1)+tzm0.group(2)

    dz_l=dz.replace(tzinfo=timezone(timedelta(hours=int(tzm))))

    dz_utc=dz_l.astimezone(timezone(timedelta(hours=0)))

    return dz_utc.timestamp()


  • 1

Reply