【问题标题】:Python: getting an object's “attribute/method/property” either as a parameter to a method or as a propertyPython:获取对象的“属性/方法/属性”作为方法的参数或属性
【发布时间】:2010-10-18 13:23:55
【问题描述】:

在 WMI 模块中(是的,我的老板希望我在 Windows 中编程——但至少它不在 COBOL 中),您似乎可以通过将 WMI 值作为方法的字符串参数传递它的名称来访问它,

blabla=wmithingy().getvalue('nameOfValue')

或作为属性/方法:

blabla=wmithingy().nameOfValue()

我是在做梦,抽着坏草,还是可以有效地做到(以及如何做到)?

【问题讨论】:

  • 你有wmithingy()的来源可以看看,看看是怎么做的吗?

标签: python windows wmi properties


【解决方案1】:

getvalue() 方法使用getattr(),或者__getattr__() 方法遵循getvalue() 方法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-12-15
    • 1970-01-01
    • 2014-07-17
    • 2019-02-01
    • 2023-01-07
    • 1970-01-01
    • 2019-01-25
    相关资源
    最近更新 更多