icalendar AssertionError:VTIMEZONEs子组件的DTSTART类型必须为datetime,而不是date

2024-05-19 23:03:11 发布

您现在位置:Python中文网/ 问答频道 /正文

在Python 3.75中运行此代码时,vscode:

from icalendar import Calendar 
import requests
SkeddaBridgeURL = 'https://bridgeartspace.skedda.com/ical?key=457bda7'
f=requests.get(SkeddaBridgeURL)
c = Calendar.from_ical(f.text)

我得到这个错误:

VTIMEZONEs sub-components' DTSTART must be of type datetime, not date
  File "/Users/jeff/Scrape/Code/skedda.py", line 6, in <module>
    c = Calendar.from_ical(f.text)

但是,当我在https://icalendar.org/validator.html处通过ical验证程序运行此URL时,没有收到任何错误

我觉得没有资格称之为bug,但也许是这样

我尝试过的一种处理方法是通过启动标志来抑制断言错误,如下所示: python 3 -Oc "Assert False"

但我不知道如何在VSCode中将其设置为标志,我也在学习

此外,在这段代码上运行调试器,通过pip3安装了icalendar,我无法进入代码或修改它。我需要弄清楚如何从github下载整个模块并删除断言吗


Tags: 代码textfromhttpsimport标志错误断言
1条回答
网友
1楼 · 发布于 2024-05-19 23:03:11

时区夏令时更改从日期开始&;时间不仅仅是一天,所以它必须是日期时间而不是日期。从https://icalendar.org/iCalendar-RFC-5545/3-6-5-time-zone-component.html

The mandatory "DTSTART" property gives the effective onset date and local time for the time zone sub-component definition. "DTSTART" in this usage MUST be specified as a date with a local time value.

各种验证器并不能从我的经验中获取所有信息,因此我尝试用我能找到的所有信息进行检查。此外,各种主要日历应用程序并不都支持RFC5545规范中的所有内容。(例如:谷歌日历在我上次检查时并没有按小时循环。)所以最好也对主要的日历应用程序进行测试。谷歌过去对文件非常挑剔,但总是没有好消息

相关问题 更多 >