Python Outlook删除了大于30天大的消息



所需的结果:
我正在尝试在我的Outlook收件箱中找到超过30天并删除这些消息的所有消息。
问题:
问题是,我最终尝试将 Time dateTime.dateTime.dateTime 进行比较。因此,我搜索并发现我可能需要使用 .strptime((。但是现在我遇到了此错误消息: valueerror:时间数据'12/06/17 16:53:43'不匹配格式'%m/%d/%d/%y%h:%m:%m:%s'。我如何获得我要寻找的结果?有更好的解决方案吗?
这是我的代码:

for folder in default_folders:
    print( "Processing %s" % folder.Name )
    item = folder.Items
    msg = item.GetFirst()
    print type(msg.CreationTime) #this gives 'time' instance
    print msg.CreationTime # prints like: 12/7/17 10:50:05
    recv_time = datetime.strptime(str(msg.CreationTime), "%m/%d/%Y %H:%M:%S").date() # <-- problem
    #datetime.replace(recv_time) i think this should be here
    past30days=datetime.now()-timedelta(days=30) # the date 30 days ago
    if recv_time > past30days: # if the recv_time date is greater than 30 days, do something 
        pass

在格式字符串中更改%y%Y%Y适用于一年的四位数(2018(,而%y则用于2(18(

最新更新