This error occurs because you are trying to access the total_seconds method on a NoneType object The NoneType object in this case refers to the return value of date_timeutcoffsetThe utcoffset method r
发生这个错误是因为您试图在一个NoneType对象上访问total_seconds()方法。在这种情况下,NoneType对象指的是date_time.utcoffset()的返回值。
utcoffset()方法返回datetime对象的时区与UTC之间的偏移量。但是,如果date_time对象没有时区信息或者设置为None,则utcoffset()将返回None。
要解决这个错误,您需要确保date_time对象在调用utcoffset()方法之前具有有效的时区信息。您可以通过在创建date_time对象时显式设置时区,或者使用其他方法来计算UTC偏移量来实现这一点。
原文地址: https://www.cveoy.top/t/topic/i1d5 著作权归作者所有。请勿转载和采集!