我试图使用Python获取邮件的接收时间,但每次都会出现以下错误
错误: 回溯(最近一次呼叫最后一次): 文件“C:/…Outlook_Automation.py”,第29行,在 接收时间=message.ReceivedTime.datetime.strftime(“%d-%m-%y%H:%m%p”) 文件“C:\Users….\AppData\Local\Programs\Python37\lib\site packages\win32com\client\dynamic.py”,第516行,位于getattr ret=self.oleobj.Invoke(retEntry.dispid,0,Invoke\u类型,1) ValueError:小时必须在0..23中我试图使用Python获取邮件的接收时间,但每次都会出现以下错误,python,python-3.x,outlook,message,Python,Python 3.x,Outlook,Message,错误: 回溯(最近一次呼叫最后一次): 文件“C:/…Outlook_Automation.py”,第29行,在 接收时间=message.ReceivedTime.datetime.strftime(“%d-%m-%y%H:%m%p”) 文件“C:\Users….\AppData\Local\Programs\Python37\lib\site packages\win32com\client\dynamic.py”,第516行,位于getattr ret=self.oleobj.Invoke
当错误状态为
ValueError:hour必须在0..23时
看起来像消息。ReceivedTime无效打印(接收时间)的输出是什么?没有输出,错误仅显示在该行之前
import win32com.client,sys
from datetime import datetime
now=datetime.now()
outlook=win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox=outlook.GetDefaultFolder(6)
messages=inbox.Items
message=messages.Getlast
received_time=str(message.ReceivedTime)
print(received_time)
received_time=datetime.strptime(received_time,"%m/%d/%y %H:%M:%S")
print(received_time)