gpt4 book ai didi

python - 无法从icalendar导入UTC

转载 作者:太空宇宙 更新时间:2023-11-03 16:58:55 25 4
gpt4 key购买 nike

我尝试运行一个包含以下行的旧脚本:

from icalendar import UTC

这给了我以下错误:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name UTC

所以我查看了 icalendar 的更改日志,其中指出了以下内容:

Renamed the UTC class to Utc, so it would not clash with the UTC object, since that rendered the UTC object unpicklable.

我将 UTC 更改为 Utc ,但仍然遇到相同的错误。

如何消除这个错误?

最佳答案

https://pypi.python.org/pypi/icalendar时区支持部分,它指出:

Instead of our own UTC tzinfo implementation we use pytz UTC tzinfo object now.

因此我建议您使用:

from pytz import UTC

...而不是:

from icalendar import UTC

关于python - 无法从icalendar导入UTC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35177971/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com