python - Python 3.7 挂起获取约会项目的 Outlook 日历开始或结束属性
问题描述
此代码在 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 来解决这个问题。
推荐阅读
- reactjs - How to update previously published app using new expo account?
- database - What's the efficient way to upload data using pdf format?
- google-play - Playstore 上的发布状态被拒绝。资格问题。应用程序不符合反短信网络钓鱼用例标准
- tensorflow - 如何使用 inception/mobilenet 模型设置 tfserving 以进行图像分类?
- r - 如何使用 R 和 dplyr 将列名粘贴为查找值
- python - 编码过程时脚本被杀死
- javascript - 如何将光标放在 IE 文本输入元素中的文本末尾
- google-apps-script - 需要有关 GoogleScript 上的 Onedit 功能的帮助(电子表格)
- android-layout - 如何从图像视图中心水平图像视图
- awk - awk 数组以意外的顺序打印元素