这段代码在python3.5.2中运行良好。在同一台机器上。在
在Python3.7.0中,当您试图让约会属性开始或结束时,它会挂起。 它只在第一个请求开始或结束时挂起。不会出现错误消息。在
在Windows10下测试,包括在命令控制台和Jupyter笔记本中。在
有什么建议或其他图书馆需要包括?在
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)
对于python3.7.0,您需要使用pywin32224(今天的最新版本)。 感谢markhammond,他生成了解决这个问题的新版pywin32。在
相关问题 更多 >
编程相关推荐