解决can't compare offset-naive and offset-aware datetimes报错

2023-02-22,,

问题描述

在比较 <class 'datetime.datetime'> 类型时,抛出异常

原因

俩个做比较的,一个具有时区,一个不具有时区

解决

如果可以确认俩个时间都是本地时间可以将时区去除掉:

data = data.replace(tzinfo=None)

解决can't compare offset-naive and offset-aware datetimes报错的相关教程结束。

《解决can't compare offset-naive and offset-aware datetimes报错.doc》

下载本文的Word格式文档,以方便收藏与打印。