expirationtime = get_end_day()

这个是过期时间的信息

datetime.datetime(2019, 5, 22, 23, 59, 59, tzinfo=<DstTzInfo 'Asia/Shanghai' CST+8:00:00 STD>)

之后在调用
push.send(data, push_time=local_time, expiration_time=expirationtime)

他总是报这个异常
LeanCloudError: [1] Failed to parse expiration time.

请问我的过期时间应该是什么类型,而且我的push_time也是差不多同一个函数得出来的,为什么效果不一样的

看起来是 Python SDK 的一个 bug,
push_timeexpiration_time 都是 datetime 对象,和云端通讯时会被编码为 UTC 时间的字符串。
expiration_time 应该编码为 2016-01-28T00:07:29.773Z 格式的字符串,但是实际上被错误编码为 2016-01-28T00:07:29.773363+00:00 格式的字符串。

感谢报告 bug,我们将尽快修复。

1 人赞了这个帖子.

python sdk 今天下午发布了 2.1.12,修复了这个问题。

def main(is_dry_run):
    IS_DRY_RUN = is_dry_run
    now = LOCAL_TIMEZONE.localize(datetime.now())
    print(now)
    query = leancloud.Installation.query.equal_to('installationId', "xxx")

    if now.hour == 10:
        body = MORN
    else:
        body = random.choice(MES)

    data = {"alert": body}

    if not IS_DRY_RUN:
        result = push.send(data, push_time=now, expiration_interval=EXPIRATION, where=query)
    print(result)

expiration_interval=EXPIRATION 这里 EXPIRATION 的定义是什么?