gpt4 book ai didi

Python 3.7 挂起获取约会项目的 Outlook 日历开始或结束属性

转载 作者:太空宇宙 更新时间:2023-11-04 06:40:40 25 4
gpt4 key购买 nike

此代码在 Python 3.5.2 中运行正常。在同一台机器上。

在 Python 3.7.0 中,当您尝试获取约会属性开始或结束时它会挂起。它仅在第一次请求开始或结束时挂断。没有错误消息出现。

在 Windows 10 下通过命令控制台和 Jupyter Notebook 进行了测试。

需要包含任何建议或其他库吗?

import win32com.client
import datetime

outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
calendar = outlook.GetDefaultFolder(9)
appointments = calendar.Items
appointments.Sort("[Start]")
appointments.IncludeRecurrences = "True"

#This block restrict the time range. Doesn't change the hang up
begin = datetime.date(2018, 9, 1) #year, month, day
end = datetime.date(2018, 10, 1)
print(f"Activities from: {begin}, to: {end}")
restriction = "[Start] >= '" + begin.strftime("%d/%m/%Y") + "' AND [End] <= '" +end.strftime("%d/%m/%Y") + "'"
print("restriction:", restriction)
restrictedItems = appointments.Restrict(restriction)

# The problem arise accessing as a unique item
appointment = restrictedItems[1]
print(appointment.Subject)
print(appointment.Organizer)
print(appointment.Start)
print(appointment.End)

# Also hangs up inside a loop of appointments
for appointment in restrictedItems:
print(appointment.Subject)
print(appointment.Organizer)
print(appointment.Start)
print(appointment.End)

最佳答案

对于 Python 3.7.0,您需要使用 pywin32 224(今天的最后一个版本)。感谢 Mark Hammond 生成了新版本的 pywin32,解决了这个问题。

关于Python 3.7 挂起获取约会项目的 Outlook 日历开始或结束属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52350165/

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