Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我试图使用Python获取邮件的接收时间,但每次都会出现以下错误_Python_Python 3.x_Outlook_Message - Fatal编程技术网

我试图使用Python获取邮件的接收时间,但每次都会出现以下错误

我试图使用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

错误:

回溯(最近一次呼叫最后一次): 文件“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中


当错误状态为
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)