Discuss / Python / 作业

作业

Topic source

太虚山寺

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

def to_timestamp(dt_str, tz_str):

# 时区转换
tz_tmp = tz_str.strip('UTC').split(':')[0]
tz_utc = timezone(timedelta(hours = int(tz_tmp)))
# 获取时间
dt_local = datetime.strptime(dt_str, '%Y-%m-%d %H:%M:%S')
dt = dt_local.replace(tzinfo=tz_utc)
# 转为timestamp
result = dt.timestamp()
return result

AirBusOne

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

你那个获取时区那个有点问题吧。


  • 1

Reply