Python:获取对象的“属性/方法/属性”作为方法的参数或作为属性

发布于 2024-09-27 14:28:29 字数 271 浏览 0 评论 0原文

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

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

或作为属性/方法:

blabla=wmithingy().nameOfValue()

我是在做梦,吸着不好的杂草,还是可以有效地完成(以及如何)?

In the WMI module (yeah, my boss wants me to program in Windows — but at least it’s not in COBOL), it seems that you can access a WMI value either by passing it’s name as a string parameter of a method,

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

or as a property/method:

blabla=wmithingy().nameOfValue()

Am I dreaming, smoking bad weed, or can it effectively be done (and how)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

故人如初 2024-10-04 14:28:29

getvalue() 方法使用 getattr()< /code>,或 __getattr__() 方法遵循 getvalue() 方法。

Either the getvalue() method uses getattr(), or the __getattr__() method defers to the getvalue() method.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文