到目前为止,这是我的代码
import win32com.client as winc
outlook = winc.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder(6)
messages = inbox.Items
message = messages.GetLast()
print message.body
并且message.body
打印我最后一封来自outlook的电子邮件。在
当我dir(message)
或help(message)
时,body
属性不来。为什么?在
为什么会这样?在
更新
有没有什么方法可以让我毫无疑问地了解一个对象的所有属性?
尝试使用^{} 方法。正如在docs中指定的那样,它列出了所有可写的属性,这样可能会有所帮助。在
根据本页http://docs.python.org/2/library/functions.html#dir
因此,我们不应该依赖}。在
dir
来了解一个对象的所有信息。如果该类实现__dir__
方法,我们将只获得从该方法返回的任何内容。他们可能实现了__dir__
,并从dir
调用中抽象出{示例:
输出
^{pr2}$答案是NO,因为作为in this case,对象的
__getattr__
方法可以被重写。考虑以下示例:相关问题 更多 >
编程相关推荐